This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
+1 vote

Godot 3.2.


Doing print(anim_player.get_current_animation()) prints nothing, so I'm led to believe that the current animation is somehow ending up being null - but strangely, the correct animation plays in-game when I trigger it, and there are no console errors.

I think the issue may be to do with the fact that I'm triggering the animation through an AnimationNodeStateMachinePlayback, so even though it refers to an AnimationPlayer's animation, the AnimationPlayer isn't actually "playing" it itself, so its current animation ends up being null.

Original Question

I am trying to set up an animation that I need to pause until some input is received, at which point it resumes. (Specifically I want to charge up for a big jump, which involves crouching, holding the crouch position to charge up, and then jumping).

I know I could do this by having separate animations for each part of the overall animation, but to me, this seems silly when it should be possible to have one animation and step through it.

What I've tried so far doesn't give me the desired effect, or does nothing at all.

In the following examples, I'm pretty sure they're both pointing to the correct nodes, and nothing else is interfering with these attributes.


anim_player.stop(false) # this is supposedly how to do it according to the docs, but for me it does nothing # gives me an error: E 0:00:01.403 seek: Condition "!playback.current.from" is true. <C++ Source> scene/animation/animation_player.cpp:1330 @ seek()

anim_player.playback_active = false # does nothing

AnimationTree: = false # pauses the animation, but upon setting it back to = true, it starts from the beginning

anim_tree.stop() and anim_tree.start() # also plays from the beginning

anim_tree.process_mode = AnimationTree.ANIMATION_PROCESS_MANUAL # also pauses the animation, but then changing it back to PROCESS_PHYSICS restarts it

I then read about AnimationNodeTimeScale, and I thought that if I set the speed to 0.0 it would pause the animation, but it doesn't seem to do anything, although I couldn't find any examples of how to get access to this node so maybe I referenced it incorrectly.

in Engine by (37 points)
edited by

have you tried to stop the AnimationTree with

atree.process_mode = AnimationTree.ANIMATION_PROCESS_MANUAL

wich will only advance when advance is called.

Hi klaas, I did also try that but found that it reset the animation to the beginning. I did it via set_process_mode() so maybe I'll try accessing it directly.

Setting process_mode gave the same result as the other animation tree attempts = the animation paused, but then reset to the beginning when I set process_mode back.

That link uses seek() which has been giving me a console error; although I do notice that if I do anim_player.get_current_animation() nothing is returned, so that's probably where to look for now.

1 Answer

0 votes
Best answer

I think the problem is that I'm using an AnimationTree with an AnimationNodeStateMachinePlayback to trigger the animation via travel(), so even though it refers to an AnimationPlayer's animation, the AnimationPlayer isn't actually "playing" it itself, so its current animation ends up being null, meaning I can't call e.g. stop(false).

The docs for AnimationTree say:

Note: When linked with an AnimationPlayer, several properties and methods of the corresponding AnimationPlayer will not function as expected. Playback and transitions should be handled using only the AnimationTree and its constituent AnimationNode(s). The AnimationPlayer node should be used solely for adding, deleting, and editing animations.

I will change the way my animation system works.

by (37 points)

I ran into this same issue after I had already built a fairly complex state machine.

Fortunately, I was able to achieve the pausing behavior I wanted by simply nesting the AnimationNodeStateMachine inside a AnimationNodeBlendTree and hooking a AnimationNodeTimeScale inbetween my state machine and the output.

blend tree example

You can then pause/resume by calling anim_tree.set('parameters/time_scale/scale', 0) on the AnimationTree. 0 pauses and 1 resumes.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.