- Home /
Animation - Normalized Time not Reaching 1.0
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);
}
}
Comment
"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
Your answer