Answer the question
In order to leave comments, you need to log in
How to implement the function: if the button is not pressed, display the animation:...?
I don't understand how, and what needs to be changed/added here so that when the buttons are not pressed, the "idle" animation is displayed, please help
if(Input.GetKey(upButton))
{
vertical = 1;
anim.Play("walk-up");
}
else if(Input.GetKey(downButton))
{
vertical = -1;
anim.Play("walk down");
} else
{
vertical = 0;
}
if(Input.GetKey(leftButton))
{
horizontal = -1;
anim.Play("walk left");
}
else if(Input.GetKey(rightButton))
{
horizontal = 1;
anim.Play("walk");
} else
{
horizontal = 0;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question