Question by
juliang478 · May 08, 2020 at 06:05 PM ·
2d-platformerflip
Sprite Flips into platform 2D
New to Unity development and I am having an issue where I come up to a wall and when I move my player away from the wall, the sprite flips into the foreground 

The code I am using to flip my sprite is:
private void FlipSprite() { m_FacingRight = !m_FacingRight;
transform.Rotate(0f, 180f, 0f);
}
I have done another tutorial game and did not have this issue, so just wondering what I am doing wrong. Any assistance is greatly appreciated.
playeratwall.png
(12.2 kB)
playerflippedintoforeground.png
(4.3 kB)
Comment
Answer by Tehemus · May 09, 2020 at 06:24 PM
I need more informations, but it seems that that the pivot of the rotation is located near the feets of your character.
Alternatively you can use the Scale Component of the Transform of your object, by multiplying the x scaling by -1.
Your answer