0 votes

What I'm trying to do:
Let's say I have a Node2D with a bunch of StaticBodies, each having own collision shapes. Can I turn off collisions (for example by disabling collision layers/masks) for all children of said Node2D using gdScript, without listing all of those StaticBodies in code?

This is just an example, what I am trying to do just requires disabling a lot of collisions at once.

in Engine by (35 points)

1 Answer

+2 votes

Can I turn off collisions (for example by disabling collision layers/masks) for all children of said Node2D using gdScript, without listing all of those StaticBodies in code?

You want groups: https://docs.godotengine.org/en/3.0/getting_started/step_by_step/scripting_continued.html#groups

Just change the layer masks of the group. I don't know if it is possible to have no layer or index, but I know you can change them.

by (1,445 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.