I've created an animation to animate a swinging mace.
To do this I select the mace object in the scene pane, open the animation pane, and key it at a certain position at 0:00.
I'm prompted to save this animation in my assets folder, which I do, as maceswing
I then rotate the mace, move the slider through time and key it in a different position. I move the slider through time again, move the object to the original position and key it.
There are now three things in my assets folder:
maceswing appears to be my animation, but I have no idea what Mace Mace 1 and Mace 2 are. (I've been mucking around trying to get this working so it's possible Mace 1 and Mace 2 are just duplicates of Mace. I still want to know what they are though)
When I play my game, the mace is constantly swinging, even though I didn't apply maceswing to it. I can't stop it. People say there's some kind of tick box to stop it constantly animating but I can't find it.
My mace object only has an Animator
component:
Unticking this component doesn't stop the animation playing so I have no idea where the animation is coming from. Or what the Animator
component actually does.
I don't want this animation constantly playing. I only want it to play once when someone clicks a certain button:
var Mace : Transform;
if(Input.GetButtonDown('Fire1')){
Mace.animation.Play('maceswing');
};
Upon clicking the 'Fire1' button, I get this error:
MissingComponentException: There is no 'Animation' attached to the "Mace" game object, but a script is trying to access it. You probably need to add a Animation to the game object "Mace". Or your script needs to check if the component is attached before using it.
There is no 'Animation' attached to the "Mace" game object, and yet I can see it swinging away constantly. Infact I can't stop it! So what's causing the animation if the game object doesn't have an 'Animation' attached to it?
My maceswing animation object: