Godot Version
4.5
Question
I am working on a game with limited animation and want to add a pause button. Because the animation is so simple, I have used several await keywords instead of the more robust Animation Player.
When I turn process mode to disabled, I noticed it doesn’t pause the animations. It works on other things that don’t rely on await, so I assume this has to do with the use of await.
I’m not very familiar with what a coroutine is. Is it possible to pause them? I’m willing to refactor my code to use Animation Players instead but I would like more information first.
Hard to help you without seeing the code.
1 Like
I made a simple case of the problem I’m trying to solve.
I would want the second sprite to be visible but not the third sprite. Is this possible using await in this manner?
Well if you don’t want third one to be visible - don’t set its visibility to true
await is not pausable, but your create_timer is pausable if you use the second argument
var tree := get_tree()
await tree.create_timer(1.0, false).timeout
print("1, will display")
tree.paused = true
await tree.create_timer(1.0, false).timeout
print("2, never seen")
1 Like
Afaik that second argument to create_timer() should be false if timer is meant to be pausable by SceneTree::paused
1 Like
Doing it with tweens would be much more convenient. Unlike coroutines, tweens can be canceled and explicitly paused at any time. You can also bind tween’s processing to the process mode of either the scene tree or a specific node.
1 Like