Flipping Tile Assets - Why Scale and Not Rotation

This is a little tricky if you don’t notice it, and it can be hard to see what is going on. In the lecture, Rick demonstrates how to flip a tile asset horizontally by changing the X axis of the scale to -1.

This works, but if you change that X value back to 1, it doesn’t flip back. That is because what it’s really doing is when you change the Scale’s X axis to -1, it also changes the Y value on Rotation to 180, and it doesn’t change it back to 0 when you reset the X scale to 1.

Before the flip:

After the flip:

Resetting the Scale (note that the rotation stayed at 180 and the asset didn’t flip back):

To fix this, you just need to manually reset that y rotation to 0.

This begs the question, why change the scale to -1 at all? You can just flip the asset by manually setting the y rotation to 180 or 0 while leaving the x scale at 1.

Is there some benefit to changing the scale to -1?

Hi Qaboom,

Thanks for sharing your solution. :slight_smile:

Yes, there is but only for the player. On the player, we have multiple colliders, and unless the collider is a simple rectangle or circle with no offset from the player’s pivot point, other solutions are fine. However, we also want to mirror the collider(s), which is why Rick changed the scale.

The problem with rotating around the y-axis is that you have to ensure that the sprite is also shown at the back surface of the mesh. This is not always the case. See, for example, this ancient thread.

Does that mean that you should always use the scale? No, it doesn’t. If you want to implement your own ideas or apply your knowledge in another context, you always have to test your idea instead of assuming that it will work just because it worked somewhere else. For example, the tilemap is not a normal SpriteRenderer (like the player’s). It comes with its own rules. For this reason, we cannot compare Rick’s solution with yours here.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms