The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

+1 vote

Hello !
I've got players, missile and obstacles in my game.
In order to have a bunch of modes in my game, I want to code in a modular way. That's why I've got :
1 layer/mask for objects which kill the player
1 layer/mask for objects which are destroyed by the player when they touches
1 layer/mask for normal collisions with the player

My question is : is it possible to know which layer triggered the collision ?

Thank you.

in Engine by (15 points)

1 Answer

0 votes

On the CollisionObject you can call collider.get_collision_layer()

Note: if your collider exists in multiple layers that the function would return a sum of all layer bits and won't work.

by (6,942 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 Frequently asked questions and 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 [email protected] with your username.