I’ve been trying to set up some basic 2d top-down controls, and I have a mostly-functioning script for animations. Thing is, it’s very messy, so I’ve been trying to transfer the information into a new script, but the “up” run animation will play for one script but not the other.
This is the old script that works:
// W is pressed, D is not
else if (Input.GetKey(KeyCode.W) && !Input.GetKey(KeyCode.D))
{
//Move at a 90 degree angle
anim.SetInteger ("RunState", 9);
sprite.flipX = false;
}
and here’s the new script, which for the most part is exactly the same but fails to function:
//Up
if (Input.GetKey (KeyCode.W))
{
anim.SetInteger ("Runstate", 9);
sprite.flipX = false;
}
The idle animation works for both scripts when I check either of them in the player component; does anybody know how to solve this?
(P.S I’d eventually like to add to the script that “if W or UpArrow is pressed,” etc. But I forgot what the or operator is in Unity. The information would be very helpful; thanks!)