Page 1 of 1

Particle effect facing direction

Posted: Sun Dec 30, 2012 10:59 pm
by dasarby
I'm trying to get a particle effect to play when the player places a gem in a daemon mouth. I can get the effect to spawn when the gem is placed, but it is only centered on the mouth when the mouth is on the north wall, any other wall the effect is still shown to the north. I set the facing of the FX from the facing of the mouth socket, but that doesn't appear to change anything.

Objects

Code: Select all

cloneObject{
	name = "hlodian_mouth_socket",
	baseObject = "mouth_socket",
	onInsertItem = function(self, item)
		if item.name == "hlodian_gem" and self:getItemCount() == 0 then
			fx = spawn("fx", self.level, self.x, self.y, self.facing)
			fx:setParticleSystem("place_gem_mouth")
			return true
		else
			return false
		end
	end,
}

cloneObject{
	name = "hlodian_gem",
	baseObject = "red_gem",
	uiName = "Hlodian Gem"
}
Particles (tweaked from the crystal):

Code: Select all

defineParticleSystem{
	name = "place_gem_mouth",
	emitters = {
		-- fog
		{
			emissionRate = 100,
			emissionTime = .5,
			maxParticles = 1000,
			boxMin = { -.2, 1.05, 1.1},
			boxMax = { .2, 	1.05, 1.1},
			sprayAngle = {0,360},
			velocity = {0.1,0.2},
			objectSpace = true,
			texture = "assets/textures/particles/fog.tga",
			lifetime = {1.5,1.5},
			color0 = {0.803922, 0.2, 0.2},
			opacity = 1,
			fadeIn = 2.2,
			fadeOut = 2.2,
			size = {.5, .5},
			gravity = {0,0,0},
			airResistance = 0.1,
			rotationSpeed = 0.3,
			blendMode = "Additive",
			objectSpace = true,
		},

		-- stars
		{
			emissionRate = 50,
			emissionTime = .5,
			maxParticles = 1000,
			boxMin = {-0, 1.1, 1.1},
			boxMax = { 0, 1.1, 1.1},
			sprayAngle = {0,360},
			velocity = {0.2,0.2},
			objectSpace = true,
			texture = "assets/textures/particles/teleporter.tga",
			lifetime = {1,1},
			color0 = {3.0,1,1},
			opacity = 1,
			fadeIn = 0.1,
			fadeOut = 0.1,
			size = {0.05, 0.13},
			gravity = {0,0,0},
			airResistance = 0.1,
			rotationSpeed = 2,
			blendMode = "Additive",
			objectSpace = true,
		}
	}
}
Is this the right way to rotate a particle effect? And am I spawning the fx right? It seems that this method creates a new fx every time the gem is is placed in a mouth; do I need to worry about leaking the fx object?

Re: Particle effect facing direction

Posted: Thu Jan 03, 2013 2:59 pm
by Komag
There are two types of coordinates in Grimrock (three really, but two for this), one is relative and the other is not. It's been a little while so I'm pretty rusty, but it looks like you are working with the static one, which means you have to make a separate object/particle for a different side. Some coordinates start in the center of the cell, others from the edge where the wall object is, it can be very tricky! Some have a constant NSEW, others are relative to the facing of the thing.

Re: Particle effect facing direction

Posted: Fri Jan 04, 2013 12:22 am
by dasarby
it looks like you are working with the static one
By that do you mean that I have this specific effect defined to use the static one, or that all effects use the static system? I looked in the script references for the option to change coordinate systems, but the only thing that seemed close was the objectSpace parameter, which i tried toggling to no avail.

Re: Particle effect facing direction

Posted: Fri Jan 04, 2013 2:32 am
by Komag
It's not something that can be defined I think, but I was never quite sure.

Re: Particle effect facing direction

Posted: Fri Jan 04, 2013 3:31 am
by dasarby
Cool thanks