I'm having some trouble with an animation. The normalized time never reaches 1.0, and the animation constantly repeats, even though it's wrap mode is WrapMode.Once.
I've posted a video that explains the issue in more detail : http://www.youtube.com/watch?v=I4WQdjMWo5Q&feature=youtu.be
Here's part of the script that plays the animation:
public void Crouching(){
// Do the crouch
if (Input.GetButton("Crouch")){
// TODO: HACK!!!
if (animation["Crouching_m"].normalizedTime < 0.8f){
animation["Crouching_m"].speed = 1;
animation.CrossFade("Crouching_m");
}
else{
//animation.Stop("Crouching_m");
animation["Crouching_m"].speed = 0f;
animation.CrossFade("Crouching_m");
}
}
else{
animation["Crouching_m"].speed = -1;
if (animation["Crouching_m"].normalizedTime > 0.0f){
animation.CrossFade("Crouching_m");
}
}
// Switch back if the animation is finished
if (animation["Crouching_m"].speed < 0 &&
animation["Crouching_m"].time <= 0){
SwitchState(EntityState.GROUNDED);
}
}
asked
Mar 28 '12 at 12:12 AM
JvJ
16
●
1
●
1
●
2
Found a solution for this? I have the same issue.
"If the animation is not set to be looping it will be stopped and rewinded after playing." A quote from the documentation on
CrossFade. This should answer you question