Pause/unpause animation in AnimationTree

Godot Version

Godot 4.2.1

Question

I need to pause my game, including animation of course. I tried setting AnimationTree to inactive, but that causes a problem: the animaiton is paused, but reactivating the AnimationTree doesnt continue the animation. The character freezes until another animation is played.
Any idea about how can I pause and restore the animation when using AnimationTrees?

Are you using get_tree().paused = true?

No, I think that would pause everything, including input. I just want to pause the game, not the ui and everything else.

You can set specific things like UI to not be paused with Process Mode “Always”. I would highly recommend using get_tree().paused for this feature.

2 Likes

I also noticed the absence of pause method on AnimationTree and AnimationNodeStateMachinePlayback, so I tried animation_tree.process_mode = Node.PROCESS_MODE_DISABLED and animation_tree.process_mode = Node.PROCESS_MODE_INHERIT. Is it what you meant by “setting AnimationTree to inactive”?

Because it worked in Godot 4.4.1: the animation continued instead of restarting.

Note: I’m using a State Machine with mostly isolated Animation nodes.