The first thing to see before starting the project are signals, signals are used to communicate between node.
In this example we will use the signal timeout to check if the timer has finished.
If you want to learn more about signals you can go to the official documentation about signals The first thing to do is to create an empty godot project and then open it.
To create a timer with godot you can simply add it in the inspector:
var timer = get_tree().create_timer(1.5) # Create a timer
await timer.timeout # waits for 1,5 second
# Do something afterwards
If you want to delete the node itself you can use queue_free() at the end.
var timer = GetTree().CreateTimer(1.5f); // Create the timer and set it to 1,5s
await ToSignal(timer, "timeout"); // Wait foor the timer to finish
// Do something afterwards
If you want to delete the node itself you can use QueueFree() at the end.
timer = new Timer();
AddChild(timer);
timer.WaitTime = 1.5f; // Waiting time
timer.OneShot = true; // If the timer is executed once
timer.Timeout += timeoutMonsterAttack;
timer.Start();
In this example the function timeoutMonsterAttack is a callback function called after the timer ends.