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

If you start the timer, pause, wait, unpause, the action that would otherwise still be waiting will be executed instantly. Thats because pausing the game does not affect the created timers. What can I do about it? Is this a bug?

in Engine by (1,124 points)

Hmmm, strange. For me, the timer is also paused and everything works as expected. I use Godot 2.1.
The behaviour that you described I would expect if Pause Mode of the timer is set to process.

Oh, no, that's not it. I'm not talking about the node Timer, no. In Godot 2.2 branch there's the method create_timer(seconds) available. You can use yield(get_tree().create_timer(seconds), "timeout") to pause a piece of code until the timer finishes. The problem is, this method still runs while paused.

2 Answers

0 votes
Best answer

Forget it, it's a bug :)
Hopefully 3.0 will come soon, can't wait!

by (1,124 points)
+2 votes

In current versions, you can create a SceneTreeTimer that stops during pause using the parameter "pausemodeprocess":

await target.ToSignal(GetTree().CreateTimer(seconds, false), "timeout");

or in GDScript:

yield(get_tree().create_timer(seconds, false), "timeout")

The default pause_mode_process=true creates timers that do not stop during pause.

Method reference:

by (40 points)
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.