I'm new to Godot and I've seen in many tutorials the Collision Layer Mask system is the way to go for setting up your collision structure. It seems like an (sort of) intuitive system for beginners, but that it would quickly become hard to manage as soon as a project gets more complex. So my question is is this system meant to be the system to use if you don't want to work against the engine, or do you use more flexible systems for your projects?

I've been using Unity quite a lot and I almost always set up my collision logic in code, checking colliding bodies and if any of them are, for example, type of Player or hold the interface Destructible, etc, I trigger certain events. Are there efficient ways of doing similar things in GDScript?

Thanks!

I use both methods. If I wanted, for example, to check whether a collision collides with a player, I'd use groups. You can check if a node is in a specific group with:

node.is_in_group("group_name") 

and get every node is a specific group with:

get_tree().get_nodes_in_group("group_name")

Collision layers are better if you want certain objects to stop colliding entirely, but still collide with some specified objects. For example, in my game I have a camera that can collide with some objects, but I set up the collision layers so that objects not in the camera collision layer won't collide with the camera.

Groups, that's a good idea. I was doing all kinds of janky things to figure out what collided.

2 years later