So, right now all I have is a recoil code making the gun fire. I want an animation to play over it, which seems easy enough. animation.Play, right? However, the animation doesn’t play with the actual fire rate of the gun, which is what I need. So is there a way to make the shooting animation match the fire rate?
1 Answer
1It sounds like what you want to do is change the speed of the animation playback, correct? In other words, you have a looping animation that plays in (say) 1 second, and the gun fires (say) twice per second, so you need to set the animation speed to (say) twice as fast.
You can do this with AnimationState - start here, with the script reference: Unity - Scripting API: Animation
Well, not exactly. For every shot thats fired, I want the animation to start from frame 1, without making the animation seem like its playing too fast. So that rules out adjusting the speed
– Pivotblimp12So can't you just use the built in animation methods to do that? Take a look at that link - there are methods to stop, rewind, and play animations. If you do that every shot, you will be restarting the animations from frame 1.
– Julien-Lynge