- Home /
Trouble With Animation - Left & Right Walking, Idle States
My Player is set to animate as walking left or right when pressing left and right arrow keys.
When the player stops, the Animation is set to have the Player Idle in the direction it was running.
However, the Player only is Idle facing one direction, and when I attempt to code it to face either direction depending on which way it was walking, it plays both very fast at 60 fps.
This is what I currently have:
if (Input.GetAxis ("Horizontal") < 0) walkLeft = true; walkRight = false; if (Input.GetAxis ("Horizontal") > 0) walkLeft = false; walkRight = true;
//if (Input.GetAxis ("Horizontal") > 0)
// walkRight = true;
// walkLeft = false;
//if (Input.GetAxis ("Horizontal") < 0)
// walkLeft = true;
// walkRight = false;
if (walkRight = true)
PlayerWalkRight ();
//else
//PlayerWalkLeft ();
if (walkLeft = true)
PlayerWalkLeft ();
void PlayerWalkRight() { //walkRight = true; //walkLeft = false; if (Input.GetAxis ("Horizontal") > 0) playerAnim.Play ("Player Running Right"); //else //if ((walkRight = true) && (walkLeft = false)) Idle(); }
void PlayerWalkLeft()
{
//walkLeft = true;
//walkRight = false;
if (Input.GetAxis ("Horizontal") < 0)
playerAnim.Play ("Player Running Left");
//else
//if ((walkLeft = true) && (walkRight = false))
Idle();
}
void Idle()
{
if (Input.GetAxis ("Horizontal") == 0)
if (walkLeft = true)
playerAnim.Play ("Player Idle");
if (walkRight = true)
playerAnim.Play ("Player Idle Right");
}
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
How do I put a delay in this? 2 Answers
Why doesn't it get my values? 2 Answers
Multiple Cars not working 1 Answer
Idle Animations, Player Walking 0 Answers