- Home /
Idle Animations, Player Walking
My Player is set, as best I can, to walk left and right and stay idle in the direction its facing.
However, the Player is only Idle in one direction. Animations are set with corresponding images.
Here is what I currently have:
horizontal = Input.GetAxis("Horizontal") movementSpeed; vertical = Input.GetAxis("Vertical") movementSpeed;
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
Multiple Cars not working 1 Answer
I can't look up and down because of animation on camera? 2 Answers
Trouble With Animation - Left & Right Walking, Idle States 0 Answers
Player plays walking animation if I press a and d at the same time while standing still 2 Answers
Character face camera direction when this pass a rotation limit 0 Answers