Godot4beta6. Doesn't work - await get_tree().create_timer(1.0).timeout
Asked Answered
H

9

0

"get_tree().reload_current_scene()" never gets executed

Happiness answered 25/11, 2022 at 23:40 Comment(0)
M
0

What about hiding the player immediately, and deferring the queue_free() until after the "await"?

Mol answered 28/11, 2022 at 22:50 Comment(0)
M
0

Try commenting-out the queue_free().

Mol answered 26/11, 2022 at 0:2 Comment(0)
H
0

Mol

so if "await" works, but I need to use queue_free()
is it bug?

Happiness answered 28/11, 2022 at 21:36 Comment(0)
M
0

Did commenting-out the queue_free() fix the problem?

Mol answered 28/11, 2022 at 21:44 Comment(0)
H
0

Mol yes

Happiness answered 28/11, 2022 at 22:14 Comment(0)
M
0

Then the problem is that the node needs to exist for a while in order for that code to work. Try moving the queue_free() after the "await".

Mol answered 28/11, 2022 at 22:27 Comment(0)
H
0

Mol
Yes, I understand, but this is to reload the scene after the player is destroyed. putting queue_free() after await no longer makes sense

Happiness answered 28/11, 2022 at 22:46 Comment(0)
M
0

What about hiding the player immediately, and deferring the queue_free() until after the "await"?

Mol answered 28/11, 2022 at 22:50 Comment(0)
H
0

Mol
It works that way, thanks
😃

Happiness answered 28/11, 2022 at 23:5 Comment(0)
U
0

Jackanapes Is this from Heartbeast's 1-Bit Godot course? looks just like it and just so happens to be the exact thing I was working on when I encountered the issue. 🙂

Thanks for the suggested solution Distribute . Once I realized that's what was happening, I created a workaround by moving the 'await timer' and 'reload scene' code into a function in the level's script, then simply called that function using get_parent(). Works like a charm now.

Uribe answered 30/11, 2023 at 1:30 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.