← PathwayLesson 4 · Collectibles, Signals & UINext lesson →

Lesson 04 · 75 minutes · Playable systems lab

Code it. Drop it. Collect it.

Create your own pickup, load its GDScript-style properties into a live lane runner, then decide whether the item belongs in a HUD, inventory, shop, storage chest, or build recipe.

AREA3DSIGNALSITEM DATAINVENTORY UICRAFTING
CODE→SPAWN→COLLECT→USE
Big ideaAn event reports that something happened; a data owner decides what it means.
PredictOne pickup should update inventory, HUD, and feedback without three separate counters.
TestCollect the same kind of item twice and compare the stored fact with the display.
Why it mattersSignals reduce tangled dependencies as a project gains more systems.
Signal Run workshop

Student sandbox · changes stay in this browser

01 / MODEL

Shape the collectible first

Choose a visual dimension, combine simple geometry, mold its proportions, and give the surface a material. Drag the 3D preview to inspect it.

2.5D ISOMETRICDrag to orbit · scroll to zoom
02 / CODE

Give it game data

The model is appearance. These exported values give the object an identity and tell the game what collection means.

Starter data is ready.
Try a remix
DISTANCE000 m
COLLECTED0
Move into a lane and collect your item.

A ← and D → move · deployed models spawn repeatedly

03 / CONNECT

Make the pickup matter

The runner emits one event. Each UI view listens to the same inventory data and gives it a different job.

SIGNAL TRACEwaiting for body_entered…
02 / BUILD

Build it in Godot

Turn the sandbox idea into a reusable scene.

collectible.tscnCollectible · Area3DMeshInstance3DCollisionShape3DPointLight3D
  1. Create the trigger.Use an Area3D root and match its collision mask to Player.
  2. Expose item data.Add an ID and value so one script can power many pickup scenes.
  3. Save and instance.Place copies across three readable lanes.
  4. Test the event.The pickup reports what happened; another system owns the result.
03 / SIGNAL

One event, many listeners

Collectibles report. Systems decide.

collectible.gd
extends Area3D
signal collected(item_id: String, value: int)
@export var item_id := "energy_cell"
@export var value := 1

func _ready() -> void:
    body_entered.connect(_on_body_entered)

func _on_body_entered(body: Node3D) -> void:
    if body.is_in_group("player"):
        collected.emit(item_id, value)
        queue_free()
Collectiblecollected(id, value)Inventory datachangedHUD · Shop · Storage
Important: A shop does not count pickups, and a collectible does not draw inventory slots. Both depend on the inventory data between them.
Godot's Signals tab showing a custom signal named health_depleted() declared in a script, listed above the node's built-in draw() and hidden() signals.
Your custom signal shows up right next to the built-in ones. A signal collected(item_id, value) line in collectible.gd makes collected appear in this same Signals tab — Godot doesn't treat custom and built-in signals differently.
Godot's Connect a Signal to a Method dialog, showing the pressed() signal being wired to a receiver node with the method name on_button_pressed.
Connecting is a real dialog, not just code. Double-click any signal in that tab and Godot asks which node and method should receive it — the same relationship body_entered.connect(_on_body_entered) sets up from script.

Screenshots: Godot Engine documentation, © Juan Linietsky, Ariel Manzur and the Godot community, CC BY 3.0.

04 / DATA

Inventory before interface

Store facts once, redraw any UI.

inventory.gd · Autoload
extends Node
signal changed(items: Dictionary)
var items: Dictionary = {}

func add_item(item_id: String, amount: int = 1) -> void:
    items[item_id] = items.get(item_id, 0) + amount
    changed.emit(items)

func spend(item_id: String, amount: int) -> bool:
    if items.get(item_id, 0) < amount:
        return false
    items[item_id] -= amount
    changed.emit(items)
    return true

Inventory

Shows what the player carries and how many of each item exist.

Build menu

Checks a recipe, spends materials once, then creates an object.

Shop

Trades one resource for another and explains why a purchase is locked.

Storage

Moves quantities between two data containers without duplicating items.

05 / REMIX

Student build sprint

Choose one complete item loop.

A

Runner boost

Collect batteries, show a three-charge meter, and spend one charge for a speed boost.

B

Base builder

Collect scrap, display a recipe, and spend three scrap to place one barricade.

C

Key shop

Collect coins, buy a key, and show the key in a non-stackable inventory slot.

D

Storage run

Collect supplies, move them into a chest, and prevent negative or duplicated quantities.

Duplicate the project as SignalRun_04_Items.Your restore point must demonstrate collect → store → display → spend or transfer.
06 / CHECK

Definition of done

Your item loop works when…

0/4 checked

Where should the true item quantity live?

Evidence: Record a 20-second test showing the quantity rise after collection and fall after building, buying, or storing.

Lesson 4 complete

Your collectible now feeds a real game system.