- Home /
My sprite is teleporting when I change my scale to -1 to flip it
A bit new to this so I'm not sure if this is a dumb question, but whenever I transform my localScale from 1 to -1 or vice versa, it does flip the sprite like I want but it also causes my sprite to teleport over in the x direction that I'm flipping towards, causing a very unnatural movement that I do not like. Is there some way to prevent this from happening?
Its a common problem and the recommended fix as always is to use the flipX and flipY properties of the sprite renderer...SpriteRenderer has these properties which you can use to easily flip the sprite, just referend the SpriteRenderer and set SpriteRenderer.flipX or SpriteRenderer.flipY as required
Answer by DevManuel · Aug 10, 2021 at 10:30 PM
Hi @rbrazee2004 , This issue is because of the pivot of your sprite. By changing the scale to-1 you are flipping the Sprite around the pivot. But your pivot is Not in the middle of your graphic and so ist flipps incorrectly.
Here is how to change the pivot. Hope it helps. Regards from Germany
Your answer
Follow this Question
Related Questions
Sprite flip movement script not working! HELP! 0 Answers
Script to flip a sprite over the x axis not working? C#, Unity2D 1 Answer
Megaman in Unity! Help with movement. 0 Answers
2D Character sprite resizes itself on movement 0 Answers
Animator warning in editor, animation is preventing script from working 1 Answer