Menu
CoddyTech

Areas Notice Bodies

Part of the Signals and Collisions section of Coddy's Godot journey. Lesson 1 of 27.

An Area2D is a zone that notices what walks into it.

An Area2D needs a CollisionShape2D child. The shape sets the area's size, here the green box. Bodies walk through an area. They do not bump into it.

When a body walks in, the area sends a signal called body_entered. This zone's script listens for it:

extends Area2D

func _ready():
	body_entered.connect(_on_body_entered)

func _on_body_entered(body):
	print("Welcome to the zone!")

_on_body_entered runs each time a body enters the shape. The next lesson explains the connect line. The robot is a body, but it walks along y = 250, below the zone.

challenge icon

Challenge

Easy

The robot walks along y = 250. In _ready(), move the zone down to y = 250. Then press Play and watch the Console.

Try it yourself

extends Area2D

func _ready():
	body_entered.connect(_on_body_entered)

func _on_body_entered(body):
	print("Welcome to the zone!")
quiz iconTest yourself

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