Flipping nested game object with particle emitter inside

I have this hierarchy for the player:

When I the player turns I flip like this:

go.set( ".", "scale.x", direction)

Which works BUT the particle effects now come out from slightly the wrong place and are… tiny! What’s the best approach to flipping a game object like this?

Have a top level parent GO which doesn’t rotate and put the particles on that, then the player is a child of the parent and you flip that?

Possibly, but the thing is I WANT the particles to be flipped. Not sure why they’re a bit offset and small when the parent game object is flipped?

Can you make a tiny reproduction example where it happens?

I don’t remember if this was an issue, but I know when I did stuff with multiple particle directions with a jetpack like example I used multiple particlefx and then just flipped the sprite. sprite.set_hflip()

Yes, and the plot thickens!

Setting scale.x keeps the collision box in the right place, but it turns out the particles are not flipped, just reduced in size. Setting euler.y works for the particles, but the collision box gets offset.

Is there a way to do this retaining both particles and collision box? Or is moving things around manually the only way?

FlipParticleEmitter.zip (27.9 KB)

Maybe @Johan_Beck-Noren can help?

And what if you do:

go.set("go2", "scale", vmath.vector3(-1,1,1))?

Or use go.set_scale("go2", -1) or go.set_scale("go2", vmath.vector3(-1,1,1))?

1 Like

Use this hierarchy:


“root” for things that should not be rotated
“pivot” for what must be rotated (must be at (0, 0, 0))
“collider” for positioning your collider (collision box must be at (0, 0, 0))

Than do go.set(“pivot”, “euler.y”, -180)

2 Likes

Same result (flipped but small particles).

ERROR:SCRIPT: /main/test.script:12: Vector passed to go.set_scale contains components that are below or equal to zero
1 Like

Thanks dmitriy! I wanted to flip the whole hierarchy out of convenience, but I suppose that’s not possible.

Your solution would work, or, in my case, it might be easier to just flip and reposition the sprite and particlefx manually and leave the collisions alone.

2 Likes