- Home /
IgnoreLayerCollision not disabling collisions
I've been trying to use IgnoreLayerCollision to disable collisions between two different sets of objects within my game but run into a problem where it simply doesn't disable the physics with hit response and detection still occurring.
Debug.Log(LayerMask.NameToLayer("projectiles")); // prints 9
Debug.Log(LayerMask.NameToLayer("Avoid projectiles")); // prints 10
Physics.IgnoreLayerCollision(9, 10, true);
Physics.IgnoreLayerCollision(10, 9, true);
Physics.IgnoreLayerCollision(9, 9, true);
Physics.IgnoreLayerCollision(10, 10, true);
I have tested to make sure i have the correct layers and additionally checked with the Physics defaults and which is set up as expected.
The objects are all on the right layer as i expect so not totally sure what is going wrong. I am working within a 2D world set up if that affects this.
Thanks in advance
Answer by MelvMay · May 25, 2016 at 03:32 PM
You use Physic2D for 2D physics. Physics is for 3D physics i.e. Physics2D.IgnoreLayerCollision.
I also presume the collision matrix above is from the 2D physics settings and not the 3D ones.