+2 votes

I use all collision layers, masks and I need more of them.
Is there a solution?

in Engine by (71 points)

1 Answer

+3 votes
Best answer

You can ask for more on github, but it is common in physics engines to have a finite amount of layers and masks, so in the worst case you will have to do some redesign in the way you use them.

You can try to optimize your use of layers by re-using them when loading different levels or contextes. For example, if in one part of the game you use layer X, but in another part it's not used, you can re-use it for a different purpose. I had this issue in another engine where we ran out of layers but we learned to live with that limitation, which isn't ideal but works just enough.

Also you can make your layers a bit more generic (instead of trying to catch every single case, which would make you run out of layers too quickly) and do filtering in your collision functions on a case per case basis depending on the execution cost you estimate.

Finally, you can also remove usage of layers in some cases. For example if you need to know if a player is inside a circular force field, instead of using a layer and a collision shape you can do a bit of math to calculate the distance from the shield's center. Ideally you would go for that solution for things that don't need much CPU resources.

by (27,660 points)
selected by

I use a Tilemap and the object is unfortunately a PhysicBody that should not collide with the Tilemap. So Add_collision_exception_with() doesn't work. And as I said all collision layers and masks are full. I really appreciate an answer, because I've been trying to solve the problem for months :(.

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.