Skip to content
Tutorials Center
My learning

Topics

Lesson 17 of 36 ยท Nodes and Signals

Node Communication in Godot: Call Down, Signal Up, Groups

Learn how Godot nodes talk to each other: call down and signal up, get_node, exported references, unique names, groups, call_group, the Event Bus pattern and what to avoid.

As a project grows, the question "how does node A tell node B something?" decides whether your game stays easy to change or turns into spaghetti. Godot gives you several tools: direct calls, signals, exported references, unique names, groups and global events. This lesson explains when to use each, and one rule of thumb that works for most situations: call down, signal up.

GDScript is read-only on this site because Godot cannot run here. A Python stand-in implements groups and call_group so you can try the pattern.

Call down, signal up

Look at a tree: Level has a Player, which has a Sprite2D and a HealthComponent.

flowchart TD
    Level -->|"calls down: methods, properties"| Player
    Player -->|"calls down"| Sprite["Sprite2D"]
    Player -->|"calls down"| Health["HealthComponent"]
    Health -.->|"signal up: died"| Player
    Player -.->|"signal up: player_died"| Level
  • A parent knows its children (it put them there). It may call their methods and set their properties directly: $Sprite2D.flip_h = true.
  • A child should not know much about its parent. When something happens, it emits a signal; the parent, which knows what to do, listens.

The payoff is reusable scenes. A HealthComponent that only emits died works in the player, an enemy or a crate. A child that calls get_parent().game_over() only works in one place and breaks when you move it.

Direct calls to children

GDSCRIPT
extends CharacterBody2D

@onready var sprite: Sprite2D = $Sprite2D
@onready var health: HealthComponent = $HealthComponent

func _ready() -> void:
    health.died.connect(_on_died)

func _physics_process(_delta: float) -> void:
    sprite.flip_h = velocity.x < 0.0

func _on_died() -> void:
    queue_free()

Cache children in @onready variables rather than calling get_node every frame.

References to non-children: exports

What if the HUD needs the player, and neither is the parent of the other? Do not write get_node("../../Player"): it breaks when the tree changes. Instead, let the parent (or the scene owner) wire them up:

GDSCRIPT
# hud.gd
extends Control
@export var player: Player          # assign in the Inspector

func _ready() -> void:
    player.health_changed.connect(_update_bar)

Dragging the player node onto the HUD's player slot stores a stable reference. Other options:

  • Unique names: mark a node "Access as Unique Name" and use %Health anywhere in the same scene.
  • A setup function: the level calls hud.setup(player) after creating both.
  • Groups (below), for "all nodes of a kind".

Groups

A group is a tag you put on nodes. Any node can be in many groups, and you can ask the tree for all nodes in a group or call a method on all of them. Add groups in the editor under Node > Groups, or in code:

GDSCRIPT
func _ready() -> void:
    add_to_group("enemies")
    add_to_group("damageable")

func _on_player_died() -> void:
    for enemy in get_tree().get_nodes_in_group("enemies"):
        enemy.celebrate()

func explode(at: Vector2) -> void:
    get_tree().call_group("damageable", "take_damage", 20)     # call on every member

Common uses: "enemies", "pickups", "player", "save" (everything that must be saved), "interactable". Test membership with body.is_in_group("player"), a clean way to check the type of what hit an Area2D. Remember to remove_from_group or let freeing the node do it. When a group might be empty, loop over get_nodes_in_group; for a single node use get_first_node_in_group("player").

Group calls are convenient but invisible in the scene: use them sparingly and name groups clearly.

Duck typing and has_method

GDScript lets you call a method on any object. To be safe on unknown types:

GDSCRIPT
func _on_body_entered(body: Node2D) -> void:
    if body.has_method("take_damage"):
        body.take_damage(10)

A cleaner option is a shared component or a base class, but has_method is a simple, flexible check ("if it can take damage, hurt it").

A global event bus

Sometimes unrelated parts of a game need to talk, such as picking up a coin anywhere updating the score label. A common pattern is an autoload script that only declares signals:

GDSCRIPT
# events.gd (autoload name: Events)
extends Node

signal coin_collected(value: int)
signal level_completed(level_id: String)
GDSCRIPT
# coin.gd
func _on_body_entered(body: Node2D) -> void:
    Events.coin_collected.emit(value)
    queue_free()

# score_label.gd
func _ready() -> void:
    Events.coin_collected.connect(func(v): score += v)

Neither node knows the other. The risks are that everything becomes global and it gets hard to trace who listens to what, so keep the bus small and use it only for genuinely global events. See Autoloads, Timers and Tweens for how autoloads work.

What to avoid

  • Reaching up: get_parent().get_parent().something() ties a scene to one exact tree.
  • Long absolute paths like /root/Main/World/Player.
  • Everything global. A "God autoload" that holds the player, the UI and all state becomes impossible to test.
  • Per-frame lookups: calling get_node or get_nodes_in_group in _process every frame.

Stand-in: groups and call_group in Python

This is not Godot. It models groups as tags kept by a tree, so you can see get_nodes_in_group and call_group.

Python Stand-in (Python): groups and call_group

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What does 'call down, signal up' mean?

    Parents know their children and may call them. Children announce events with signals so they stay reusable.
  2. 2. What is the best way for a HUD to hold a reference to a Player elsewhere in the scene?

    Exported references survive tree changes and make dependencies visible.
  3. 3. Which call runs a method on every node in a group?

    SceneTree.call_group calls the named method on each member of the group.
  4. 4. What is a risk of an event bus autoload?

    A big global bus hides who connects to what, so keep it small.

Summary

  • Parents call down into their children; children signal up to their parents.
  • Use @export references, unique names (%Name) or setup functions instead of fragile long paths.
  • Groups tag nodes; use get_nodes_in_group, call_group and is_in_group for "all of a kind".
  • has_method gives flexible duck typing; a tiny signal-only autoload can serve as an event bus.
  • Avoid reaching up the tree, global state for everything and per-frame lookups.

Next: Autoloads, Timers and Tweens