0 votes

I have a project that is a 2D Game with a "fake" 3D depth (like in the 90's brawlers)

For collisions I was thinking if changing the characters/items (when they move) collision layers and masks would be a good solution.

But I am worried that it might be a problem in performance.

What do you think?

in Engine by (370 points)

Why do you want to change them when they move? Is there a problem leaving them on?
I don't see a problem in changing them, you can do stress-tests in your game and see if you get lag spikes.
The only thing to be careful about is that changing layers dynamically is not instant, it's applied only the next frame due to the order in which Godot processes scripts and collisions.

Because if the player moves up/down, for example, I would want to make him collidable with item/enemies on the same y axis plane. So I would change the player layer or mask to match the items'.

Ah, yeah that makes sense. Well as I said, that should not cause performance problems. If you want to be sure, profile it ;)

1 Answer

+1 vote

don't use the body itself to detect collisions, use a raycast (or more) that will detect all collision layers. to answer your question, that is going to slow down your game (more than I have expected)

by (523 points)

Thanks! I did not test in my project, cause in the end I chose not to use the collision masks. But at least I know that it can be a performace issue.

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.