Conditional Collision?

Is it possible to check a collision and decide whether or not to “obey” the collision?

For example, if there are a set of Good Guys and a set of Bad Guys, the Good Guys can walk through other Good Guys’ bounding boxes, but they collide with Bad Guys. Bad Guys can walk through other Bad Guys, but collide with Good Guys. Is there a way to do this with rigidbodies, or will I have to write my own collision/physics from scratch? This is in 2D if it makes a difference.


EDIT: In the event I can’t use rigidbody2D’s, can I still use the Collider2D and manually check for collisions if I use transform.translate? Sorry, I’m new and having trouble finding my way around the API and how it all links together :stuck_out_tongue: thanks again.

You can do this by using Layers and the Collision matrix. Create two layers and assign bad guys one layer and the good guys the other. Then in the collision matrix toggle the checkboxes so the bad guys layer can not collide with itself and the same for the good guys layer. That should be all, you can still use rigid bodies and all that, nothing else needs to change.