- Home /
Question by
ProjectCryken · Jul 20, 2014 at 10:37 PM ·
javascriptcollisionphysicslayers
Check if layers can collide
Is there a way to check if two given layers are currently set to collide or not in the physics settings. I have a vast array of layers set to ignore collisions with certain others and it would great if I could check in code.
So basically:
IF (objectA.layer can collide with objectB.layer) DO THIS
Comment
Best Answer
Answer by rutter · Jul 20, 2014 at 10:56 PM
You want Physics.GetIgnoreLayerCollision.
Two layers can collide if collisions between them are NOT ignored, which makes for a sort of confusing double negative:
if (!Physics.GetIgnoreLayerCollision(objectA.layer, objectB.layer)) {
//do something
}
Wonderful! $$anonymous$$new it would be there somewhere, just couldn't find it. Thanks!