How can I pause/resume animation playing in State Machine

I need to pause/resume animation from animation blueprint( derived from custom UAnimInstance) Animation is playing from State Machine (not Anim montage). And it should be preferably done from c++ code

What is the best way to do it?

Thanks in advance

1 Like

I would use the GlobalAnimRateScale on the SkeletalMeshComponent. You can see that the animation is ticked that way in the code:

AnimScriptInstance->UpdateAnimation(DeltaTime * GlobalAnimRateScale);

GlobalAnimRateScale is public so you should be able, from your custom AnimInstance, to simply do this :

GetOwningComponent()->GlobalAnimRateScale = 0.0f;//Pause
GetOwningComponent()->GlobalAnimRateScale = 1.0f;//Resume

I havent tried it myself, but this should work!

Mick

Inside the character class, I used
GetMesh()->bPauseAnims = true;

which is the same as you can see in the editor, when you open the character, under Animation there is a “Pause Anims” flag.