This is the testing Godot forums! All forum posts unique to this forum will be deleted! Please use the main forums here for any posts you want to keep. All forum rules still apply.

Are you using the Collision Layer Mask system?

peterhoglundpeterhoglund Posts: 1Member

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!

Comments

  • DschoonmakerDschoonmaker Posts: 216Member

    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.

  • KequcKequc Posts: 114Member

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

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.