Hello,
In the Tilevania project Rick flips sprites on the x axis using its local scale. He uses code
transform.localScale = new Vector2(-(MathF.Sign(myRigidbody.velocity.x)), 1f);
Is there a reason MathF.Sign is used instead of using:
transform.localScale = new Vector3(-transform.localScale.x, 1f);
Both flip the sprite and act as expected. Not sure if this is a standard convention or Rick’s preference.
edit For reference, Rick used the MathF.Sign originally in the player movement as we are collecting input and don’t know what direction the player was heading. So it made sense to pull out the sign and use it. But with the Enemy we are just saying “if you hit a wall, turn around.” Pulling the sign doesn’t seem necessary unless there is some case I am missing.