How to check if animation has finished?

m_pMesh->PlayAnimation(s_pAnimJump, 0);
float animLen = m_pMesh->GetSingleNodeInstance()->GetLength();

If you wait for the animation to end, and then play the other, you’ll get a little hitch, so I would take a bit of time off:

animLen -= 0.34f;

Now you can set a timer or something to kick off the next step. For example:

GetWorldTimerManager().SetTimer(PostAnimTimerHandle, this, &MyActor::PostAnimFunc, animLen, false);

I recommend that instead of using m_pMesh->PlayAnimation(s_pAnimJump, 0); you use:

float animLen = m_pMesh->GetAnimInstance()->Montage_Play(MyMontage);

Because montages have the nice blend-in, blend-out feature, return the anim length right off the bat, and have many convenience functions such as pause and skip to section. If you don’t want a hitch between animations, simply account for the blend-out time.

animLen -= MyMontage->BlendOutTime;
1 Like