Play animation on button held

Updated on October 15, 2017 in [A] Animation
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
0 on October 15, 2017

(tittle)

basically creating script who will allow player to make sneak
Created animations and controller like this: picture
The problem it won’t do animations, script is this:

 
public Animator anim;
 
void Start()
 {
 anim = GetComponent();
 }
void Update ()
 {
    if (Input.GetKeyDown("q"))
    {
        anim.Play("LeftSneak");
    }
    if (Input.GetKeyDown("r"))
    {
        anim.Play("RightSneak");
    }
 }
 

I’ve created a Animator to a player and dragged one into it. Why it won’t work? (Unity 2017.1.1f1 personal version)

Oh and I’ve tried Input.GetButton(). Won’t work aswell

  • Liked by
Reply