I am having troubles setting up my gun animation. I created a gun and am trying to set up a simple shoot animation which is called in the script when the Fire1 button is pressed.
void Update() {
If (Input.GetButtonDown ("Fire1") ) {
animation.Play("Shooting", PlayMode.StopAll);
}
}
I keep getting the error
“MissingComponentException: There is no ‘Animation’ attached to the “Gun” game object, but a script is trying to access it.”
I have a Animator Component attached to the Gun so I’m not sure why I’m getting this error. Could someone help?
On a side note, when I initiate the game the animation starts once, I am also unable to disable this initial animation. If I could get some advise for how to stop this it would be much appreciated
I am relatively new to Unity and am using C# scripts, so any help would be greatly appreciated.