- Home /
Animation problem - Only one animation plays
Hello. I'm making a little skiing game and I made 2 animations for grabs. a "mute" grab and a "safety" grab. The problem is, I can only get one of them to play depending on which one I place last in the code. It's as if the second one overrides the first animation.
private var turning : TurningScript;
private var safety : AnimationState; private var mute : AnimationState; private var grab : GrabScript;
function Start() { // find the current instance of the turning script: turning = FindObjectOfType(typeof(TurningScript)); // find the current instance of the grab script: grab = FindObjectOfType(typeof(GrabScript));
mute = animation["mute"];
safety = animation["safety"];
}
function Update() { if(!turning.isGrounded) { if (grab.right) { safety.speed = 1; animation.CrossFade(safety.name); } else { safety.speed = -1.5; animation.CrossFade(safety.name); } safety.normalizedTime = Mathf.Clamp01(safety.normalizedTime);
if (grab.topRight)
{
animation.CrossFade(mute.name);
mute.speed = 1;
}
else
{
animation.CrossFade(mute.name);
mute.speed = -1.5;
}
mute.normalizedTime = Mathf.Clamp01(mute.normalizedTime);
}
}
Answer by commodore · Jun 11, 2012 at 02:04 AM
I think I fixed it. I removed "animation.CrossFade(mute.name);" from the else statements and it seems to work fine now! woohoo
Your answer
Follow this Question
Related Questions
CrossFade won't crossfade animation, it just jumps to it. 0 Answers
How to use CrossFade with anim2 when anim1 is over? 1 Answer
Why is Animation Not Playing in Reverse? 2 Answers
Animation/CrossFade difficulties, Animation won't CrossFade 0 Answers
Can the animation editor create local rotational data? 3 Answers