Area2D
⚠️ Experimental - Pre-Release
Inheritance Hierarchy
Area2D is a 2D area node used for collision detection. It extends Node2D and provides area-based collision functionality.
Fields
Area2D has no additional fields beyond those inherited from Node2D.
Inherited Fields: Area2D has all fields from Node2D: transform, pivot, visible, z_index
Signals
Area2D nodes automatically emit signals based on their name field when objects enter, occupy, or exit the area. The signal naming follows a pattern:
NAME_Entered- Emitted when an object first enters the areaNAME_Occupied- Emitted while an object is inside the areaNAME_Exited- Emitted when an object leaves the area
For example, if an Area2D node has name = "Door", it will emit "Door_Entered", "Door_Occupied", and "Door_Exited" signals.
@script DoorHandler extends Node fn init() { // Connect to Area2D signals by the area's name Signal.connect("Door_Entered", on_door_entered) Signal.connect("Door_Exited", on_door_exited) } fn on_door_entered() { Console.print("Player entered the door area") } fn on_door_exited() { Console.print("Player left the door area") }The Area2D node doesn't need any script attached - it automatically emits these signals based on collision detection. Any script can listen for these signals by connecting to the appropriate signal name. See the Signals documentation for more information.
Basic Usage
@script TriggerArea extends Area2D fn init() { // Area2D for collision detection self.name = "Trigger" // Will emit: Trigger_Entered, Trigger_Occupied, Trigger_Exited }Related
- Node2D- Base 2D node
- CollisionShape2D- Collision shape node
