# Flipping nested game object with particle emitter inside

**URL:** <https://forum.defold.com/t/flipping-nested-game-object-with-particle-emitter-inside/54920>\
**Category:** Questions\
**Created:** [June 14, 2019, 7:51pm UTC](https://forum.defold.com/t/flipping-nested-game-object-with-particle-emitter-inside/54920 "2019-06-14T19:51:08Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![totebo](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/totebo/32/36087_2.png) [@totebo](https://forum.defold.com/u/totebo)\
**Post date:** [June 14, 2019, 7:51pm UTC](https://forum.defold.com/t/flipping-nested-game-object-with-particle-emitter-inside/54920/1 "2019-06-14T19:51:08Z")

</div>

I have this hierarchy for the player:

 ![50](https://forum-defold-uploads.b-cdn.net/original/3X/3/6/36abba852b20da80773440d175912a06662dda6d.png)

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?

---

<div class="post-metadata">

**Author:** ![Pkeod](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pkeod/32/606_2.png) [@Pkeod](https://forum.defold.com/u/Pkeod)\
**Post date:** [June 14, 2019, 9:38pm UTC](https://forum.defold.com/t/flipping-nested-game-object-with-particle-emitter-inside/54920/2 "2019-06-14T21:38:38Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![totebo](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/totebo/32/36087_2.png) [@totebo](https://forum.defold.com/u/totebo)\
**Post date:** [June 14, 2019, 10:32pm UTC](https://forum.defold.com/t/flipping-nested-game-object-with-particle-emitter-inside/54920/3 "2019-06-14T22:32:01Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Pkeod](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pkeod/32/606_2.png) [@Pkeod](https://forum.defold.com/u/Pkeod)\
**Post date:** [June 14, 2019, 10:41pm UTC](https://forum.defold.com/t/flipping-nested-game-object-with-particle-emitter-inside/54920/4 "2019-06-14T22:41:11Z")

</div>

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()

---

<div class="post-metadata">

**Author:** ![totebo](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/totebo/32/36087_2.png) [@totebo](https://forum.defold.com/u/totebo)\
**Post date:** [June 18, 2019, 10:38am UTC](https://forum.defold.com/t/flipping-nested-game-object-with-particle-emitter-inside/54920/5 "2019-06-18T10:38:22Z")

</div>

> [@Pkeod](#):
>
> Can you make a tiny reproduction example where it happens?

Yes, and the plot thickens!

 ![Group%206](https://forum-defold-uploads.b-cdn.net/original/3X/a/2/a2d6a117eed167881494fabf40b2c777e1c93ed6.png)

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](https://forum-defold-uploads.b-cdn.net/original/3X/c/6/c6d7663562824fc64f4ed9efb589019fe9357a33.zip) (27.9 KB)

---

<div class="post-metadata">

**Author:** ![Pkeod](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pkeod/32/606_2.png) [@Pkeod](https://forum.defold.com/u/Pkeod)\
**Post date:** [June 18, 2019, 10:54am UTC](https://forum.defold.com/t/flipping-nested-game-object-with-particle-emitter-inside/54920/6 "2019-06-18T10:54:43Z")

</div>

Maybe @Johan_Beck-Noren can help?

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [June 18, 2019, 12:31pm UTC](https://forum.defold.com/t/flipping-nested-game-object-with-particle-emitter-inside/54920/7 "2019-06-18T12:31:06Z")

</div>

> [@totebo](#):
>
> Setting scale.x keeps the collision box in the right place, but it turns out the particles are not flipped, just reduced in size.

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))?`

---

<div class="post-metadata">

**Author:** ![dmitriy](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/dmitriy/32/18452_2.png) [@dmitriy](https://forum.defold.com/u/dmitriy)\
**Post date:** [June 18, 2019, 1:03pm UTC](https://forum.defold.com/t/flipping-nested-game-object-with-particle-emitter-inside/54920/8 "2019-06-18T13:03:25Z")

</div>

Use this hierarchy:

 ![59](https://forum-defold-uploads.b-cdn.net/original/3X/9/b/9bbdc8d6b6b2aeda6c9efdc475f4075fa73046c1.png)  
“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)

---

<div class="post-metadata">

**Author:** ![totebo](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/totebo/32/36087_2.png) [@totebo](https://forum.defold.com/u/totebo)\
**Post date:** [June 18, 2019, 1:24pm UTC](https://forum.defold.com/t/flipping-nested-game-object-with-particle-emitter-inside/54920/9 "2019-06-18T13:24:42Z")

</div>

> [@britzl](#):
>
> go.set(“go2”, “scale”, vmath.vector3(-1,1,1))

Same result (flipped but small particles).

> [@britzl](#):
>
> Or use `go.set_scale("go2", -1) or go.set_scale("go2", vmath.vector3(-1,1,1))?`

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

```

---

<div class="post-metadata">

**Author:** ![totebo](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/totebo/32/36087_2.png) [@totebo](https://forum.defold.com/u/totebo)\
**Post date:** [June 18, 2019, 1:27pm UTC](https://forum.defold.com/t/flipping-nested-game-object-with-particle-emitter-inside/54920/10 "2019-06-18T13:27:57Z")

</div>

> [@dmitriy](#):
>
> must be at (0, 0, 0)

Thanks [dmitriy](https://forum.defold.com/u/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.
