The first thing to see before starting the project are signals, signals are used to communicate between node.
In Godot, signals are a way to send notifications that something has happened. They are similar to events or callbacks in other programming languages. Signals allow nodes to communicate with each other without needing to reference each other directly — this keeps your code clean, modular, and decoupled.
A signal is a message emitted by an object when something happens — like a button being pressed, a character finishing an animation, or a timer reaching zero.
You can:
Emit a signal (broadcast it).
Connect to a signal (listen to it and respond).
Godot nodes often have built-in signals. For example, a Button has a signal called "pressed".
# Assume this is attached to a scene with a Button node named "MyButton"
func _ready():
$MyButton.connect("pressed", self, "_on_MyButton_pressed")
func _on_MyButton_pressed():
print("The button was pressed!")
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:
In Godot, a Timer is a node (Timer) that lets you trigger actions after a certain amount of time has passed, or repeat actions at regular intervals.
Timers are useful for:
| Property | Description |
|---|---|
| wait_time | Duration (in seconds) before the timer times out |
| one_shot | If true, it runs once and stops |
| autostart | If true, it starts automatically when the scene runs |
| loop | If true, it repeats after each timeout |
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.