A
A
Agillar2022-03-06 01:19:44
Unity
Agillar, 2022-03-06 01:19:44

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

1 answer(s)
F
Farawa, 2022-03-06
@Agillar

In the animator, make a boolean field, move the arrows from Idle to wolf and back, and in the script, just set when the button is pressed or released, just check for input.mousebutton(0)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question