Add Mixing Transform Doesn't Work!!

Hi

I’ve made this work on a character currently in my scene, but I just can’t get it to work on the newest character I have added.

Here is the scripting I have been using

function Start ()
{
animation[“machineGunShoot”].layer = 14;
animation[“laserShoot”].layer = 14;

var mixShootLaserGun : Transform = transform.Find("waistM/back1M/back2M/RclavicleM/RshoulderM/RelbowM/RwristM/Rcannon1M");

animation["laserShoot"].AddMixingTransform(mixShootLaserGun);

var mixMachineGun : Transform = transform.Find("waist/back1/back2/Lclavicle/Lshoulder");

animation["machineGunShoot"].AddMixingTransform(mixMachineGun);

}

function Update ()
{
if (Input.GetAxis(“R_Trigger”) > 0.1 && animation.IsPlaying(“idle”))

	animation.Play("laserShoot");

}

Can anyone see any problems with what I have done? Or help me understand why it isn’t working?

Thanks

The code you’re using before the Update function never gets used because you’re just playing your standard lasershoot animation. add Debug.Log(“Laser Shooting”); before the animation.play(“laserShoot”); to see if the if statement is executed.

I just tried that, and the animation is playing. It just isn’t isolating the bones I want to play the animation on :confused:

It should work, because I used the same code for a character in the same game (obviously defining different bones) I just don’t understand why it will work for one character and not for another!

I think you missed some ( and ).

Try with that :

function Update () { if ((Input.GetAxis("R_Trigger") > 0.1) && (animation.IsPlaying("idle")))

    animation.Play("laserShoot");
}

Not sure if this is related, but whenever I set AnimationState.layer to anything other than the default (0), I get a null reference exception.

Try removing the part where you change the ‘animation[“animName”].layer’ at the start and see if the exception goes away.