Should I use Collision Layer and Masks?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By peterhoglund

I’m still very new to Godot and trying to figure out the best workflows for me. I am wondering about Collision Layers and Masks. I’m moving over from Unity which also has a system of Tags and Layers however these are not widely used. I used Layers sparsely to separate raycast hits sometimes. Instead, I did almost all my collision checks in code and I got the feeling this is the case for most people using Unity.

So, coming into Godot I see the Collision Layer and Mask system being used in several tutorials saying this is the way to do collision sorting in Godot. Would you say that this is the case? Should I “work with the engine” and adopt this system? Just starting I get the sense that this system might work well for very small projects but might get bloated or impossible to use when a project increase in complexity.

In Unity I would set up a system where when two objects collide I check if one of them, for example, is of type Player or hold the interface Destroyable etc. What is the best way of doing similar checks in GDScript?

Thank you!

I don’t know for certain but I think it’s because in Godot you can assign multiple layers by clicking checkboxes (it’s similar to the collision matrix in Unity but it pertains to each node) and group names (tags) to one node whereas in Unity each GameObject has one drop-down box for both so it will only let you set one layer and one tag so it’s quite limited in Unity.

Magso | 2020-06-16 10:04