No input with Input.GetKey()

using UnityEngine;
using System.Collections;

public class WeaponAnimControl : MonoBehaviour {

// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {
Animator anim = GetComponent();
Animation anima = GetComponent();
int RightClick = Animator.StringToHash (“RightClick”);
if(Input.GetKey (KeyCode.Mouse2)){
anim.SetBool(RightClick, true);
anima.Play (“aimdownsights”);
Debug.Log (“Aiming Down Sights”);
}
else{
anim.SetBool(RightClick, false);
anima.Play (“idle”);
Debug.Log (“Idle-ing”);
}
}
}

When I right click, neither the Bool or the animation play. In addition, the console doesn’t print anything out.
What am I doing wrong?

It’s not made expressly clear in the docs, but I’m pretty sure GetKey only works for keyboard input. Try Input.GetMouseButton or Input.GetButton instead.

Thank you, but it still won’t work.
I can’t understand what I’m doing wrong. Also, my gun disappeared when I play now.

Why is my gun teleporting?
I use an animation, and the gun just teleports.
I’m not understanding. it’s attatched to the Main Camera in the First Person Controller.
Why does it teleport way way waayyyy out in space?

Turn off root motion in your animation settings.

When posting code please use code tags.

Thank you all. I WAS GETTING SO ANNOYED but now I got it. Thanks so much!

Now I just need to figure out how to mark this as “Solved”.