- Home /
Overlapping dynamic Rigidbody2D objects
I have two objects that I want gravity to work on, but I want them to overlap... If I have a Rigidbody2D dynamic on both, then they stack one on top of the other, and any other body type doesn't apply gravity to them... any ideas? Thanks!
You can specify which objects will collide with others using the collision layer matrix. Set your two objects to have their own layer then untick the collision between the same layer in the collision matrix. The collision matrix is located in Project Settings > Physics2D. Find the layer name you assigned to your objects and untick the box corresponding to that layer on both the horizontal and vertical axis.
Thanks! Is there any way for me to still detect collision between the two objects?
You can do it manually by constantly checking if their materials overlap. Or you can add an empty GameObject as a child to your main object, set it to another layer and add a collider2d to it with the same size as the parent object. Don't add a rigid body. Set the collider to trigger mode. Then you can detect when they touch and overlap each other with the OnTrigger...() events.