• Unity
  • "Proper" animation exit time?

Related Discussions
...

So, currently I've been using 85% into an animation for my exit time so that there's enough time to transition into the new animation. I've since discovered that Mix is .2s not 20%, so does that mean we should try to start our SetAnimation call from trackEntry.Animation.Duration - trackEntry.MixDuration to perform a "perfect exit and mix?"

This is important because I have events where I need to fire towards the end of animations but also look good. We have gotten around this in the past before the new event threshold was implemented by making sure no animations were after 85% into an animation, but now that we can implement mixing events I am re-evaluating how you're "supposed" to exit NON-LOOPING animations properly.

Yes, start mixing from A -> B at A.duration - mixDuration. If you were using AnimationState addAnimation to queue the next animation, when you pass 0 for delay it does exactly that.

Nate a écrit

Yes, start mixing from A -> B at A.duration - mixDuration. If you were using AnimationState addAnimation to queue the next animation, when you pass 0 for delay it does exactly that.

This doesn't work for all situations.. .2s does not work at all for .5s animations, so if default mix is .2s you need to exit at the greater of Animation Duration - trackEntry.MixDuration vs. Animation Duration * .85% it seems.


03 Dec 2016, 14:45


//set the desired exit time to the animation duration minus mix duration of the track
//if the exit "duration" is less than the mix time, instead set the exit time to 85% into the animation
desiredExitTime = trackEntry.Animation.Duration - trackEntry.MixDuration;

//the calculated time that this anim will exit with the desired exit time
float exitDuration = trackEntry.Animation.Duration - desiredExitTime;

//if the exit duration is less than the mix, change the exit time to something more reasonable
if (exitDuration < trackEntry.MixDuration)
{
    desiredExitTime = trackEntry.Animation.Duration * exitTime;
}


03 Dec 2016, 14:46


Am I not using SetAnimation correctly where I should be using Add? We don't use Add anywhere in our game.

Majicpanda a écrit

.2s does not work at all for .5s animations,

Of course it works. You mean a 0.2s mix doesn't look like you want for your 0.5s animation? Often you'll want to set a default mix, then customize mixes between specific animations so they look good. Some will need a shorter or longer mix, there is no way to generalize this. Eg, a jump animation probably uses a very short mix time, since the user expects the jump to happen very quickly after they press the button.

Majicpanda a écrit

Am I not using SetAnimation correctly where I should be using Add?

AnimationState addAnimation queues an animation for playback after a delay. If you know you want to play A and then B, you can set A and then add B. It's also fine to set A and then have some code later set B at the right time.