Skip to main content
Thursday, December 3, 2026 New tutorials published every day
Home
Free Tools
Typing Test New JSON Formatter Base64 Encoder / Decoder Password Generator Text to QR Code Generator Word Counter Case Converter Age Calculator Color Converter Number to Words All Free Tools
Projects
PHP Projects — all projects
Students
Webflow Course Course Registration Download Syllabus Verify Certificate Student Leaderboard
Resources
WordPress Plugins Search tutorials About CodingCush Contact
More
Login
Game Development

Godot 4 Signals Explained: How Nodes Talk to Each Other

Learn Godot 4 signals with a coin-collect game: custom signals, connecting in code or the editor, signals with arguments, and five mistakes to avoid.

A signal in Godot 4 is a message a node sends when something happens. A button sends one when it gets pressed, and a coin sends one when the player touches it. Any other node can listen for that message and run a function when it arrives, and the sender never needs to know who is listening. Think of a doorbell. The button by the door has no idea who lives in the house, and it does not need to know. It rings, and whoever is inside decides what to do about it. A signal works the same way. This post builds a coin game to show you how, with code run in Godot 4.3 first. If you would rather watch the lesson, the video version is in the Godot 4 Full Course in Hindi, free on YouTube.

What a signal is, in plain words

Every node in Godot can send signals, and every node can listen for them. The sender is the emitter, the message is the signal, and the function that runs when it arrives is the receiver. A signal carries no return value and waits for no answer. It announces that something happened, and then it is done.

Godot ships with built-in signals on most nodes. A Button has pressed. A Timer has timeout. An Area2D has body_entered, which fires when a body walks into it. You can also define your own: a coin can announce collected, a player can announce died, a level can announce finished. Since Godot 4.0, signals are a first-class type, so the editor can autocomplete them instead of making you spell their names as strings.

Signals exist so your nodes can stay strangers to each other. The coin does not need a reference to the score label, and the score label does not need to know what a coin is.

The coin game we will build

The example for this post is small on purpose: a coin, a score label, and a button. The player walks into the coin, the coin announces it, and the score goes up by one. Every bigger use of signals is the same shape with more nodes.

The scene tree looks like this. Main is a Node2D. Under it sit Coin (an Area2D with a CollisionShape2D and a Sprite2D), a Label called ScoreLabel, and a Button called CollectButton. The coin uses the Godot icon as its sprite. If you want fruit sprites instead, grab our free Catch the Fruit art pack. The player walks with the arrow keys, with the movement script from how to move a character in Godot 4 with GDScript.

Step 1: give the coin a signal of its own

Attach a script to the Coin node and write this:

extends Area2D

signal collected

func _ready():
    body_entered.connect(_on_body_entered)

func collect():
    collected.emit()

func _on_body_entered(_body):
    collected.emit()

The line signal collected defines a new signal. Name signals with a past-tense verb, because a signal reports something that just happened: pressed, collected, died. The _ready function connects the Area2D's built-in body_entered signal to a function on the same script, so walking into the coin triggers _on_body_entered, which calls collected.emit(). The collect() function does the same thing on demand, so you can test the signal from the button.

Notice what the coin does not do. It never touches the score, and it never looks for the label. It only announces that it was collected. Drop it into any scene, connect its signal, and it works.

Step 2: connect the signal in code

Now attach a script to the Main node:

extends Node2D

var score = 0

func _ready():
    $Coin.collected.connect(_on_coin_collected)

func _on_coin_collected():
    score += 1
    $ScoreLabel.text = "Score: " + str(score)

The connection happens in _ready, which Godot calls once when the node enters the scene. The line $Coin.collected.connect(_on_coin_collected) reads almost like English: connect the Coin's collected signal to this script's _on_coin_collected function. From then on, every time the coin emits collected, Godot calls that function, which adds one to score and writes the new total into the label. Tested headless in Godot 4.3: one collect() call moved the score from 0 to 1.

The Godot 4 editor with the CollectButton selected and the Signals dock open on the right, listing the Button signals button_down, button_up, pressed and toggled
The Signals dock in the Godot 4 editor, showing the CollectButton's signals. pressed() is the one this post uses.

The no-code way: connect a button in the editor

Code is not the only way to connect a signal. Select the CollectButton, open the Node tab at the top right of the editor, and click Signals. The dock lists every signal the button can send. Double-click it, and the editor offers to create a receiver function on a node with a script. Accept, and Godot writes the function for you, named _on_button_pressed by convention.

Here is the same idea from Godot's own getting-started tutorial, where a button starts and stops a spinning sprite:

extends Sprite2D

var speed = 400.0
var angular_speed = PI

func _process(delta):
    rotation += angular_speed * delta
    var velocity = Vector2.UP.rotated(rotation) * speed
    position += velocity * delta

func _on_button_pressed():
    set_process(not is_processing())

Each press calls _on_button_pressed, which flips processing on or off with set_process(not is_processing()). The editor connection and the code connection do the same job, and the editor one saves you typing the connect line. Use the editor for buttons you build by hand, and code for nodes you spawn from a script. Godot's own signals tutorial walks through this button example step by step.

Signals you will meet every week

Most of your signal work will use a small set of built-ins:

Node Signal When it fires
Button pressed() The player clicks or taps the button
Button toggled(toggled_on) A toggle button switches state
Timer timeout() The timer runs out
Area2D body_entered(body) A physics body walks into the area
CanvasItem visibility_changed() The node is shown or hidden

The Timer one is worth remembering on its own, because timers show up everywhere: skill cooldowns, weapon reloads, enemy spawn waves. Connect timeout in _ready, the same way the coin connected body_entered.

When a signal needs to carry a number

Sometimes the news is not enough, and the listener needs a value with it. A health bar does not just need to know that health changed. It needs the new number. A signal can declare arguments for that:

extends Node2D

signal health_depleted
signal health_changed(old_value, new_value)

var health = 10

func take_damage(amount):
    var old_health = health
    health -= amount
    health_changed.emit(old_health, health)
    if health <= 0:
        health_depleted.emit()

The signal health_changed(old_value, new_value) promises two numbers, and the emit call passes them in the same order. The receiver must accept two parameters, in the same order, or Godot complains. The Signal class reference lists everything else you can do with a signal, including checking whether it is connected.

Five mistakes that stop signals working

Most broken signals come from one of five small slips. First, the connect line sits in _process instead of _ready, so it runs sixty times a second and the function fires sixty times per signal. Connect once, in _ready. Second, get_node has the wrong name, because the node was renamed in the editor and the script still uses the old one. Third, a typo in the signal name or the function name. The editor's Signals dock shows the exact spelling, so copy it from there. Fourth, the signal is emitted before anything connects to it. Nothing happens, and no error appears. Fifth, the same signal is connected twice, so the function runs twice per emit.

Frequently asked questions

Do I have to use signals, or can I call functions directly?

You can call functions directly, and for two nodes that always work together, that is fine. Signals earn their keep when the sender should not know who is listening.

Can one signal call more than one function?

Yes. Connect as many listeners as you like to the same signal, and Godot calls each one when it fires. A coin's collected signal can update the score, play a sound, and spawn a sparkle, all from one emit.

What is the difference between a signal and a function call?

A function call names the receiver. A signal does not. With a call, the caller must hold a reference to the receiver. With a signal, neither side knows the other exists.

Do signals work the same in every Godot 4 version?

The basics here work in every Godot 4 release. Signals became a first-class type in Godot 4.0, and the code in this post was run in Godot 4.3. Godot 3 uses different syntax for the same idea.

Try it yourself, then keep going

Now it is your turn. Add a second coin to the scene and connect its signal to the same function, then add a Timer that hides the coin for a few seconds. If you want a bigger playground, wire the coin signal into a real game: our Snake game art pack gives you the sprites, and every food pickup in Snake is a signal waiting to happen. The video version of this lesson is in the Godot 4 Full Course in Hindi, free on YouTube.

Lavkush
Written by

Lavkush Super Admin

Lavkush Kumar is a software developer with over 6 years of experience turning ideas into websites and web applications. He holds a Master of Computer Applications (MCA) degree and enjoys building for the web, exploring new tools, and sharing what he learns along the way.

Through CodingCush, Lavkush creates easy-to-follow tutorials and practical guides to help students and beginners learn software development without feeling overwhelmed. His approach is simple: learn by doing, build real projects, and keep improving one step at a time.

Whether you’re just starting out or looking to sharpen your skills, CodingCush is all about making learning practical, beginner-friendly, and fun.

0 Comments

Leave a Comment