I’m adding gem pickups to my game for an extra challenge.
A gem sits inside a brick, then falls out when the brick breaks, and the paddle should be able to grab it.
A gem should only collide with the paddle (for pickup) and the pit (for self-destruction if you fail to pick it up). I implement this with layers for each class of game object.

To embed a gem into a brick, I simply make the gem a child of the brick.
- Brick
- Gem
So the brick holds it in place at first.
public class Brick : MonoBehaviour {
void Awake () {
foreach (Transform child in transform) {
var body = child.GetComponent<Rigidbody2D>();
if (body != null) {
body.gravityScale = 0;
}
}
}
When the brick breaks, it releases the gem, and gives it a new parent (otherwise the gem would be destroyed too).
Destroy(gameObject);
--NumBreakables;
foreach (Transform child in transform) {
child.parent = transform.parent;
var body = child.GetComponent<Rigidbody2D>();
if (body != null) {
body.gravityScale = 1;
}
}
Here is where my problem occurs. The released gem doesn’t collide with anything. Debug printing showed no calls to Gem.OnCollisionEnter2D or Gem.OnTriggerEnter2D.
I tried a few different ways to hold and release the gem. None of them made an apparent difference.
- gravityScale = 0 then 1
- bodyType = Static then Dynamic
- Sleep() then WakeUp()
I suspect the answer lies in how I change the parent. Doing so properly may be more involved than it appears to be. Some observations to support my hypothesis:
- If I place a gem without a parent brick, it does collide with the paddle and pit as it should.
- If I allow brick/gem collisions, gems instantly collide with the containing bricks (and thus are both destroyed).
- If I allow gem/gem collisions and place a free gem above an embedded one, the free one falls and the gems do collide (and thus are both destroyed).
I could hack around all this by checking object tags on collision instead of using layers. But I’d rather learn about the collision layering system and what makes it break in this case.
See Gem.cs and Brick.cs:
The gems’ physics properties:

