- Home /
make 2 object not collide?
i have 2 objects with colliders. One is a player and one is a rigidbody. i want them to collide with everything(floor, walls, clones of self, etc.) except each other. How do i do that?
Answer by Seth-Bergman · Mar 14, 2013 at 01:54 AM
The easiest way is with the Collision layers matrix
http://docs.unity3d.com/Documentation/Components/LayerBasedCollision.html
create a layer for each object (select the object, choose "add layer")
the first 8 (layer 0-7) are reserved (built-in layers..) use any of the user layers (8 up)
select the object again, after creating a new layer, to make sure it is set to that layer
then uncheck the layers from their intersection in the matrix
edit>project settings> physics
By the way, if this answer helps solve your issue, be sure and click the CHEC$$anonymous$$ $$anonymous$$AR$$anonymous$$ to accept it! (I notice you have alot of unaccepted questions, this may make it less likely to get good answers!)
This probably only works for 3D bodies. I'm trying this with 2D colliders and it's not working.
I got it to work for 2D. I used DryTear's solution, except Unity also has it for Physics2D. So I ended up putting Physics2D.IgnoreLayerCollision(8, 9, true);
in the Start() method of a script. Now the layers don't collide.