Groups and Collisions

Problem

Godot's collision engine relies on a series of signals and callbacks, but there's only one function for all of collision! (This is in contrast to Game Maker, which usually has a per-object idea of collision)

How do you make sure you're colliding with the right thing?

Collision Layers

https://docs.godotengine.org/en/latest/tutorials/physics/physics_introduction.html#collision-layers-and-masks

Each collision shape exists on one or more collision layers, and only triggers events for other collision objects that exist on the layers present in its collision mask.

Groups

http://docs.godotengine.org/en/latest/getting_started/step_by_step/scripting_continued.html#groups

If you have one specific node (say, from the result of a collision), you can use

node.is_in_group("group_name")

to determine what to do with it. This is another tool beyond collision layers that can be used to filter collisions!