A Door That Opens
Part of the Signals and Collisions section of Coddy's Godot journey. Lesson 16 of 27.
To free another node, call queue_free() on that node:
$Door.queue_free()This script is on Main, the root of the scene. A plain queue_free() would free Main and every node in the game with it.
The amber door is a StaticBody2D, a solid body that never moves, like the walls. You cannot walk through it until it is freed.
Challenge
EasyMain already listens to the green plate. When you step on it, free the Door. Then walk through the gap.
Try it yourself
extends Node2D
func _ready():
$Plate.body_entered.connect(_on_plate_body_entered)
func _on_plate_body_entered(body):
pass
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Signals and Collisions
Practice on your own: Godot playground