# Getting particles to emit from one point on the actor

Member Posts: 287
edited November -1
I have a ship that I want to spew out steam/smoke from it's thrusters. I have the emitter off-set at (0,-25), relative to actor, which is the base of it. However, whenever my actor rotates, the emissions still come from the same point. The particles don't spawn from the base of the ship, but as what (0,-25) would be if the ship were at a 90 degree angle.

Oh, and second particle related question, I have the particles emitted whenever I press the up arrow key and accelerate. When I let go and press it again, past particles disappear instantly before their lifetime's up. Nulo's platformer's robot's jet pack's (lol) particles stay 'til their destroyed. ... how exactly do I do this?

• Member, PRO, Chef Emeritus Posts: 1,803
1. Do relative to scene and add the offset of the actor's position.

2. Nulo uses a Timer and spawn actor
• Member Posts: 478
I have a similar issue, but I want the particles to emit from the same coordinate point at the rear of the ship no matter what the rotation.

The particles are set 'relative to actor' so the particle spray follows the direction of the actor and sprays correctly.
(I've tried setting the particles 'relative to scene' and found the spray is directed down no matter what the rotation of the actor.)

However, the 'emitter offset' does not behave as expected. If the ship rotates 90' right the emitter still sprays in the right direction but its position is off at the bottom of the actor.

Currently I have the co-ords at 0,0 so at least the spray is correct.

How do I fix this? ....Simple fix or expression?
• Member, PRO, Chef Emeritus Posts: 1,803
sines and cosines.

say you had a 100x100 actor and you wanted to spray particles from the middle of the right edge.
if it didn't rotate then the offset would be (50, 0).
That is similar to saying at rotation=0 degrees, the offset is (50*cos(self.rotation) , 50*sin(self.rotation)) = (50*cos(0),50*sin(0)) = (50*1,50*0) = (50,0)
• Member Posts: 478
Nooooo I knew these things would re-appear at some point in my life..... Sin, Cos Tan (Soh/Cah/Toa) now I really have to learn them again...... sigh.

I just want the particles to stay where they are and rotate properly relative to the ship. Cant this be a behaviour?

Tried a few versions of the expression above, trying to make it work - Gamesalad just crashes on Preview for me.
I'm guessing my expression is wrong or incorrect?
• Member, PRO, Chef Emeritus Posts: 1,803
I would double check what you entered.

For my Particles behavior in the Velocity/position tab I entered in the expression editors:

Emitter Offset X: 50*cos(self.Rotation)
Emitter Offset Y: 50*sin(self.Rotation)
Direction: 0
Speed: 120

And set it relative to actor. The '50' is the distance from the center of the actor.

Although if you wanted a different starting point you would add offsets to the angle like so.
Emitter Offset X: 50*cos(self.Rotation+20)
Emitter Offset Y: 50*sin(self.Rotation+20)

If you really wanted to get fancy (or lazy), you could use the vectorToAngle function to get the offset angle
Emitter Offset X: 50*cos(self.Rotation+vectorToAngle(50, 50))
Emitter Offset Y: 50*sin(self.Rotation+vectorToAngle(50, 50))
• Member Posts: 478
Still has a little trouble when I added an offset - the offset needed to be outside the brackets 22*cos(self.Rotation)+20

I found this worked ok to put emitters on each side of the ship. (Compromise but it actually works better I think)

Emitter Offset X: 22*cos(self.Rotation)
Emitter Offset Y: 22*sin(self.Rotation)

Emitter Offset X: -22*cos(self.Rotation)
Emitter Offset Y: -22*sin(self.Rotation)

Thanks for the help.
• Member Posts: 4,172
Math? I didn't know there was going to be MATH!

I remember High School math class. I asked, "When am I ever going to use this stuff?" She didn't have an answer. When I started doing stuff in Flash, after reading Jobe Makar's book on Flash game design, I realized (many years later) that game development was the correct answer.

Anyway... six months after the last post here... I'm hitting the same problem. I was impressed when my little space craft was spewing out thrust. But when I turned the ship, the thrust stayed in the same spot. I tried the various Emitter Offsets listed here. My character is 64x64, so I think the number 22 or 50 should be replaced with 32 for my project.

X, that's the left Emitter Offset field?
Y, that's the right Emitter Offset field?
(I switched them to be sure, but nothing happened.)

Without any rotation, the offset for the left thruster is -8, -35
Without any rotation, the offset for the right thruster is 8, -35

I tried the lazy way... 50*cos(self.Rotation+vectorToAngle(50, 50))
I tried 22*cos(self.Rotation)+20
I tried 22*cos(self.Rotation+20)
I tried relative to Actor
I tried relative to scene
...but when I put in the math stuff, my particles don't display.

Also, what's the performance hit on particles? Two thrusters means 40 particles on the screen. Is that something I should be concerned about?
• Member Posts: 4,172
I figured out why it wasn't working. I can't just paste in the phrase "self.Rotation" as an expression. It has to be in the blue bubble thing.

Now I just have to figure out the math.
• Member Posts: 256
Sorry to bring this old topic up, but curious - how do you get a particle / smoke trail for a rocket to stay on
the screen until it reaches it's 'touch' destination? basically like a missile command game... just want the smoke trail to follow the rocket all the way and not disappear after like 40 pixel distance?

thx.