- Home /
How to set facing direction in my case?
Hello,
I'm developing a 2D top-down game where the player controlled by 8 direction keyboard movement. For this movement I'm using lerp along with horizontal and vertical axis. I programmed the facing direction properly while the player is moving, but when he is stop (release arrow keys) the facing direction set back the default "look forward" state. It's unacceptable as he need to face the same direction when he stopped.
rigidb.velocity = new Vector2(Mathf.Lerp(0, Input.GetAxis("Horizontal") * walkSpeed, 0.25f),
Mathf.Lerp(0, Input.GetAxis("Vertical") * walkSpeed, 0.25f));
transform.up = rigidb.velocity;
How can I fix this issue? It is really annoying for me!
Answer by Namey5 · Jul 24, 2019 at 03:03 AM
All you need to do is make sure there's some kind of input when assigning the rotation, i.e.
if (Input.GetButton ("Horizontal") || Input.GetButton ("Vertical"))
transform.up = rigidb.velocity;
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
How do I make bullets pass through some game objects? 1 Answer