Unity3D C# Ani

Hello, I’ve created a Gun Animation for my FPS gun and I made a secondary script that access my Shooting script (which is on top of a empty object at the tip of my gun) and I’m having a hard time calling that animation, as I cant see what the problem is actually. I’ll post my animation script below

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

I get the error, There is no ‘Animation’ attached to the “gun2” game object, but a script is trying to access it.

And in the animator, I got my animation set as default, I even drag n dropped it onto the gun so…is it a bugg or what?

The animation reference is the legacy animation system. If your gameObject has an Animator attached to it the animation reference is useless. You will have to getcomponent for the Animator then change a variable for the animator which will change the animator a state to the gunshot animation.