C# animator bool

Hello, just wondering if anyone can take a look at my code and tell me why my animation aint playing on input.getbutton(“Fire1)” please. Im trying to set a bool which gets true when input is pressed, else it’s false, so the animation will play according to that. `public class GunAnimation : MonoBehaviour
{

private Animator animator;
void Start () 
{

}


void Update () 
{
	if (animator) 
	{
		AnimatorStateInfo stateInfo = animator.GetCurrentAnimatorStateInfo(0);
		if(stateInfo.nameHash == Animator.StringToHash("gunIdle"))
		{
			if(Input.GetButton("Fire1")) 
				animator.SetBool("gunShoot", true );
		}
		else
		{
			animator.SetBool("gunShoot", false);				
		}

	}
}

}

I tried to check the unity script reference, the videos with no luck…

Hey Sveyh, I had the same problem and I solved it by typing `public class GunAnimation : MonoBehaviour {

void Start ()
{
	
}


void Update ()
{
	if (Input.GetButtonDown ("Fire1")) 
	{
		Shoot skott = GetComponentInChildren<Shoot>();
		if(skott.ammoPerClip > 0)
		{
			animation.Play ("shootanim");
		}
	}
}

}

`