I've got a weird issue in my game where a collision is happening DESPITE that specific interaction between the two layers being disabled in the Collision Matrix (images attached).
I have the following code used to debug as well:
protected void OnCollisionEnter(Collision collision)
{
Debug.Log($"Collision between {LayerMask.LayerToName(gameObject.layer)} and {LayerMask.LayerToName(collision.gameObject.layer)}");
}
The output is
Collision between PlayerProjectile and EntityMovement
but this should be disabled.
I have checked and double checked the layers on the objects in question, and they are correct/as intended.
My game object setup is probably a bit complex but when boiled down, this seems like it should be simple, yet for some reason it doesn't work.
check the hierarchy. if the object you given the collider doesn't have a rigidbody attached, then it will go to the parents and looks for the rigidbodies. check if the layer set on the rigidbody in parent is what you expect it to be. if you want children have a different layer then you have three options
1- give all of the children rigidbodies
2- make an object in the same position of parents and make all of the colliders children of that. then write a code to fix the position of this object as the parent
3- make a parent for all the children under your rigidbody and give a rigidbody to that.