Scaling on Y in collection different ingame vs in editor (#3215)

Describe the bug (REQUIRED)
I flipped one of the objects in a collection along the Y-axis in the editor to make a RHS-version.

See below:

In-game, the flip is not reflected:

14%20pm

Expected behavior (REQUIRED)
I expected the editor to show the same as what occurred in-game.

Defold version (REQUIRED):

  • Version 1.2.168

Platforms (REQUIRED):

  • Platforms: macOS
  • OS: [e.g. iOS8.1, Windows 10, High Sierra]
  • Device: Macbook Pro 15"

Oh, hey, it works if you set Z scale to -1 as well.

I believe we have an issue with the editor being able to set a negative scale value.
This is not something we intend to support I’m afraid.

1 Like

That’s disappointing, as you can see it’s extremely useful.
I would love it if we could keep it.

You can achieve the same effect by a combination of y and z rotations :wink:

2 Likes

Thanks I’ll give this a try. Hopefully this fixes the other issue I was having (non-bug) with negative scaling flipping the rotation direction of mirrored turrets in calculations (i.e. positive angles rotate anti clockwise).

Issue: https://github.com/defold/defold/issues/3215

Hey guys!

Looks like I’m on the right topic… :sweat_smile: (sorry to dig up old stuff, but I suppose it’s still better than creating a new topic right? you tell me)


(this is a game object composed of smaller game objects)

image
(scale -1 in X since I have the exact same game object on the other side… the original one… just imagine some sort of symmetric arena)

When I launch the game, the negative scale is ignored:

Will the issue be fixed in the near future (would be cool) or do you recommend to find a workaround(1)?

(1) If so, do you think I should generate this game object (and its children) when the scene appears and then mirror it in runtime (in init function)? Or is there a better way to proceed?

PS : not sure to understand the" rotation in Y and Z" thing. :thinking:

You’ve stumbled upon the following issue:

In general it is not recommended to set a negative scale to flip things. Two solutions:

  1. You can flip sprites at runtime
  2. Add a flipped versions of graphics to your atlas by creating a one frame animation referencing the same image and checking the Flip Horizontal box. Note that this will not increase the size of your atlas.
3 Likes

Thanks!

I’ll try to avoid the second solution if possible (for the reason you mentioned), but…

If I flip the sprite, what will happen to the collision object (since they are at the same level in the hierarchy)?

ex:
image

Will it keep its original orientation or will I need to flip it too? (if so, how? Is there a way to flip a collision shape?)

Why? There is no disadvantage to the second solution, besides the extra work of adding a one-frame flipbook animation in the atlas (which will NOT impact atlas size).

The collision object will not be affected. Remember that the Sprite is a component and the sprite.set_hflip() function operates on that component only.

BUT

Yes, physics.set_hflip() will flip the shape horizontally.

2 Likes

Oops sorry, I misread this: “Note that this will not increase the size of your atlas.” (I ignored the “not”… :see_no_evil:)

Thanks for the answer(s)!

2 Likes

I stumbled on this issue right now, but with a model. Is there a model.set_hflip() on the horizon? Or is it Feature Request time?

Nope. It makes sense to flip a sprite or a 2D physics shape, but is flipping 3D models a thing one wants to do?

1 Like

Well, I certainly longed to do this recently! I am building a racing game track out of pieces, each piece is a model. One example, seen straight from above:

90_45

Flipping this to get the left turn would save time (and download time for the player). For the symmetrical track parts this can be solved by rotating them on the z axis, but the plan is to add non symmetrical ones too, and that’s when h-flip would be very handy.

Ok, got it. Please go ahead and create a feature request and link it here!

Thanks, done! https://github.com/defold/defold/issues/5815

1 Like