Changing between animations problem

Hello everyone. I got a problem about changing some animations. I have sniper system. And I have a weapon bob animation when player is in scope. And I also have another animation which is a recoil animation, which is used when player fires if it’s in scope. Here is that recoil animation :

alt text

alt textalt text

and problem is, when I fire to the point, it hits, and then Recoil animation comes in, but it doesn’t come from the position which I hit, it goes to the main position of the camera and starts from there.

alt text

so What I want to tell is, is there a way to start an animation from the position which is camera in, not from it’s original animation positions ? Or is there any other way to make good recoil effect on scope ? I need your advices and help, here is my code for animations :

 if (inScope) // if we are in Scope
  {
     animation.CrossFade("weaponBob"); // make a weapon Bob
      if(Input.GetKeyDown("Fire1")) // if fired when in Scope
    {
      AnimateUp(); // work the recoil animation function
    }
   }

function AnimateUp() {
animation.CrossFade("recoil"); // I tried codes like CrossFadeQueued but they didn't help, or I used them wrongly.
yield WaitForSeconds(0.8);
animation.CrossFade("weaponBob");

}

thanks :slight_smile:

Your problem is related to the necessity of COMBINING (mixing) animations rather than playing them singularly. In particular, I believe that you need your recoil animation to be of the 'Additive' type.

Animation mixing (different than simple blending) is a somewhat complex subject, but you should be able to solve your problem with a simple

animation["myrecoilanimation"].blendmode = AnimationBlendMode.Additive;

If this doesn't cut it, you'll need to clearly specify which bone is the source of the additive interaction.

Detailed info and example here: http://unity3d.com/support/documentation/Manual/Animation%20Scripting.html

(you're interested in this section)

function Start () {
   // Adds a mixing transform using a path instead
   var mixTransform : Transform = transform.Find("root/upper_body/left_shoulder");
   animation["wave_hand"].AddMixingTransform(mixTransform);
}