- Home /
How to flip 2d character walk movement?
I am working on a 2d platformer prototype and I am having trouble animating my player across the screen. He faces right when I press the right arrow key to move him. When I press the left key, he still faces right but moves in the opposite direction. I can't seem to make him face to the left. His animations are very simple to make because he doesn't have any legs. Is there a solution to this?
Answer by Zoelovezle · Dec 24, 2015 at 11:44 AM
The new Unity Update allowes you do that without changing the transform.localScale.
Check here : http://docs.unity3d.com/Manual/class-SpriteRenderer.html
Answer by DevPrime01 · Jan 05, 2019 at 02:21 AM
I'd rather use Euler Angles
if (isRight == true && isLeft == false) {
transform.eulerAngles = new Vector3(0, 0 ,0);
}
if (isRight == false && isLeft === true) {
transform.eulerAngles = new Vector3(0, 180, 0);
}
}
Hey man, quick question Why would you use Euler Angles ins$$anonymous$$d of using localScale to flip the character?
Answer by LazyElephant · Dec 24, 2015 at 11:14 AM
You can make the sprite flip to the left by changing the transform.localScale. They go over it in this live training session.
Your answer
Follow this Question
Related Questions
What is the best/easiest way to align a 2D rigidbody to specific sections of a sprite? 1 Answer
Having some stuck issues on the 2D infinite runner 0 Answers
2d shooting problem 1 Answer
2D Detect collisions of a 2D block only on left/right (not top/bottom) 0 Answers
so I'm trying to make a 2D platform but the first animation i make is the only one that registers 0 Answers