I have an animation on my rifle that is basically a recoil (kickback) that it triggered every time the 'Fire1' is pressed. But because it is playing the same recoil animation over and over again it looks a little bit 'fake'.
It is possible to add a slight random rotation animation to the recoil animation, so every time the recoil is played, the rotation differs slightly.
Now, currently I have got a script that changes the rotation randomly, but its not animation - so it looks like its 'snapping' (doesn't look smooth):
SIG is the gun model.
To get a smoother result, you could do something like adding one or more secondary animations designed to sync up with your current recoil animation and act on top of them with layers, using a synclayer if necessary and setting weight or using Blend to randomly set the effect of your offset on top of your recoil.
The correct approach would be to have your recoil be based on your gunshot direction and could be done in several different ways from separate animations for different gunshot positions or simplifying your recoil animation or using physics or driving that part of the animation in code.
My suggestion is to look into using AnimationState layering. You could have a few AnimationClips applied and running simultaneously and weight the layers differently to achieve 'natural' results.
Have your standard recoil AnimationClip on layer 1, and then set another animation clip which controls only the rotation on layer 2. This rotation should be the maximum in which you want to rotate. From there, just before you tell these animations to play, you randomly choose a value between 0 and 1 and assign that to the weight of the rotation animation (layer 2). The blending that occurs will take into account the weight and should give you slightly randomized recoil which is unique every time.
Note: This is a very basic explanation and I am likely missing a couple details, but that should give you the general idea of where to look/start.
Hope that helps.
answered Nov 15 '10 at 04:15 PM