Menu
CoddyTech

Is It in the Group?

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

Checking body.name works for one node. For a set of nodes, check the group:

if body.is_in_group("racers"):
	print(body.name, " finished!")

is_in_group() answers yes or no. Use it even for one node. A name changes when you rename or copy a node. A group says what the node is.

Three robots run to the finish line. Red and Blue are in the group racers, set in the scene. Bot cleans the track and is in no group.

challenge icon

Challenge

Easy

The finish line prints a line for every robot that crosses it. Make it print only for racers. The Console should show Red finished! and Blue finished!, and nothing for Bot.

Try it yourself

extends Area2D

func _ready():
	body_entered.connect(_on_body_entered)

func _on_body_entered(body):
	print(body.name, " finished!")
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