- Home /
weapon sprint animation problem...
Hi. I have created this script, which controls the walking, sprinting and idle animations that are attached to my weapon.
static var walking : boolean=false;
static var sprinting : boolean=false;
function Update () {
if(walking==true){
animation.CrossFade("walk");
}
if(sprinting==true){
animation.CrossFade("sprint",0.2);
}
if(walking==false && sprinting==false){
animation.CrossFade("idle");
}
}
Another script controls the walking and sprinting booleans. When the sprinting animation is CrossFaded it plays about half of the animation clip, then glitches between the sprinting and walking poses. Youtube Video Of The Problem...
Answer by whydoidoit · Jun 30, 2012 at 09:07 AM
Is it possible that both are true? I'd suggest making the second and third if statement "else if" instead. Then also verify that you can't be both walking and sprinting. You would probably be better of using an enum rather than booleans to maintain state with more than two possibilities.
Just a tiny adjustment... And it works correctly. I should have spotted it before! - Thanks.
if(sprinting==true){ walking=false; animation.CrossFade("sprint");
}
Your answer
Follow this Question
Related Questions
Problem to import animation in unity 2 Answers
Problems with animated entity 1 Answer
Help with textures 0 Answers
Animation problem with rotation and position. 0 Answers
Custom Weapon Animation 2 Answers