Teleportation particle system with MeshShape

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
Post Reply
User avatar
Zo Kath Ra
Posts: 931
Joined: Sat Apr 21, 2012 9:57 am
Location: Germany

Teleportation particle system with MeshShape

Post by Zo Kath Ra »

When I spawn a monster (or teleport it in), it suddenly appears out of thin air.
If the player can see this, it gives the impression that the mod is unfinished.

Andak Rainor suggested using the "teleportation_effect" object, which uses the "teleportation" particle system:
viewtopic.php?f=22&t=18255&p=117091#p117094

It doesn't look bad, but the particle system always has the same shape, and it's often too big for the monster.

So I simply added this to all emitters of the "teleportation" particle system:
emitterShape = "MeshShape",

Code: Select all

defineParticleSystem{
	name = "teleportation_new",
	emitters = {
		-- fog
		{
			emitterShape = "MeshShape",
			spawnBurst = true,
			emissionRate = 0,
			emissionTime = 0,
			maxParticles = 10,
			boxMin = {-1.0, 0.5,-1.0},
			boxMax = { 1.0, 2.5, 1.0},
			sprayAngle = {0,360},
			velocity = {0.1,1},
			objectSpace = true,
			texture = "assets/textures/particles/fog.tga",
			lifetime = {0.5,0.5},
			color0 = {0.190294, 0.365000, 0.450490},
			opacity = 0.3,
			fadeIn = 0.2,
			fadeOut = 0.2,
			size = {2, 2},
			gravity = {0,0,0},
			airResistance = 0.1,
			rotationSpeed = 0.3,
			blendMode = "Additive",
		},

		-- stars
		{
			emitterShape = "MeshShape",
			emissionRate = 1000,
			emissionTime = 0.2,
			maxParticles = 1000,
			boxMin = {-1.5,-0.5,-1.5},
			boxMax = { 1.5, 2.5, 1.5},
			sprayAngle = {0,30},
			velocity = {0.5,1.5},
			objectSpace = true,
			texture = "assets/textures/particles/teleporter.tga",
			lifetime = {0.4,0.6},
			color0 = {1.8,1.8,1.8},
			opacity = 1,
			fadeIn = 0.01,
			fadeOut = 0.4,
			size = {0.1, 0.3},
			gravity = {0,-1,0},
			airResistance = 0.1,
			rotationSpeed = 2,
			blendMode = "Additive",
		},

		-- small stars
		{
			emitterShape = "MeshShape",
			emissionRate = 1000,
			emissionTime = 0.2,
			maxParticles = 1000,
			boxMin = {-1.5,-0.5,-1.5},
			boxMax = { 1.5, 2.5, 1.5},
			sprayAngle = {0,30},
			velocity = {0.5,1.0},
			objectSpace = true,
			texture = "assets/textures/particles/teleporter.tga",
			lifetime = {0.4,0.6},
			color0 = {1.6,1.8,1.8},
			opacity = 1,
			fadeIn = 0.01,
			fadeOut = 0.4,
			size = {0.05, 0.1},
			gravity = {0,-0.5,0},
			airResistance = 0.1,
			rotationSpeed = 2,
			blendMode = "Additive",
		}
	}
}
On some monsters, it looks perfect:
- herder

But on others, the particle system is too high:
- forest_ogre
- fjeld_warg
- sand_warg (not as pronounced as the sand_warg)

Has anyone experiemented with this and come up with a particle system that better follows the monster shape?
minmay
Posts: 2768
Joined: Mon Sep 23, 2013 2:24 am

Re: Teleportation particle system with MeshShape

Post by minmay »

ParticleComponents with emitter meshes will use the unposed mesh, which for monster meshes is usually not a good pose. If you want to emit particles from a posed mesh you have two options:

1. MonsterComponent's deathEffect field. This particle system will play when the monster dies, at whatever location and in whatever pose the monster was in when it died. So you could spawn a dummy monster and immediately call its die() method to play the deathEffect. Of course, this does require spawning a monster with all its rigging and so on, so it's not great for performance, and the object (including the dead MonsterComponent) will stick around until the particle system finishes. If you do this, make sure that your dummy monster is flying so it doesn't trigger pressure plates, and toggle Console.suppressWarnings() before and after spawning so that you don't get the "invalid spawn location" warning.

2. UggardianFlamesComponent. This requires a MonsterComponent too; its particle system will follow the monster's animations. Look at the uggardian and air elemental monsters in the standard assets for examples. Unfortunately, UggardianFlamesComponent is rather finicky compared to ParticleComponent; you can stop it but you can't restart it, dynamically adding/removing it may not work properly, and I'm not sure having multiple on the same monster will even work.

For your case, you almost certainly want option 1.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Post Reply