Await - simpler than using tween

Hi,

Isn’t a simpler approach to a 1-second delay using await (see below) or is there some other benefit to using tween in this situation?:

await get_tree().create_timer(1.0).timeout
get_tree().reload_current_scene()
6 Likes

This is the way. Tweens should be used for animation purposes: Tweens - Godot documentation.

I agree that tweens should be used for animation purposes however with using the await you can introduce race conditions if something is using what you are awaiting and its not ready in time.
We didnt want to add that level of complexity at this stage of learning but if we make a more advance Godot course we will of course be using an await rather than a tween.
However it does work and does show that you can use other methods especially in prototyping to get things working.

So you think using a tween functionality with a special syntax at the end to load the next scene is less complex than a simply command (await)?

I am happy to learn of both ways as an somewhat “experienced beginner” but for me a simple timer looks far more easy than a mechanic normally used for a different topic.

I always comment my code for me for later reference and the tween part got quite some text. The await version would have gotten none. Just for you to know how some beginners might think :slight_smile:

2 Likes

I have to agree with the others here that “await” was basically meant for this kind of functionality, and should be used over “tween” if all we want is to cause a timed pause in the execution queue. I may agree that its inline nature might scare beginners away, but it is still simpler than having to explain the whole tween framework, which is equally complex because it works asynchronously and requires a callback event handler. All in all, I believe a single line is still simpler to explain than the asynchronous Tween framework, when all we want is to cause pause.

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms