- Home /
Disable all collisions but one?
Is it possible to turn off all collisions for one object except with just one other object? I.e. I want object A to only collide with object B and nothing else in the scene.
I'm looking for something like:
Physics.IgnoreCollision(objectA, all);
Physics.IgnoreCollision(objectA, objectB, false);
Answer by alibatiste · Mar 18, 2014 at 04:25 PM
you can use the layer and the "Layer collision matrix" in Edit=>projetc setting=>physics
That forces me to create a special layer just for this one object, right? Not a very good solution.
you still have 30 other :D. I don't see any other solution...
What if I have 50 such objects? :P But thx for trying. It's possible that, once again, unity just sux. :P
Answer by l3mon · Sep 30, 2020 at 05:37 PM
Only Alternatice I could think of is using the OnCollisionEnter()
or OnTriggerEnter()
functions... You could check the game object's tag in case you don't want to go for layers, but it's similar.