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.
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")
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.