diff --git a/src/entities/SmashItemManager.js b/src/entities/SmashItemManager.js index f855fc4..bfe9d7a 100644 --- a/src/entities/SmashItemManager.js +++ b/src/entities/SmashItemManager.js @@ -67,6 +67,15 @@ export default class SmashItemManager { friction: SMASH_ITEM.friction, frictionAir: SMASH_ITEM.frictionAir, restitution: SMASH_ITEM.restitution, + // Never collide with the bus's kids. Kids ride at the open top of the + // compartment, so an item slamming into the bus (or a smashed item + // launched up-and-forward) could otherwise knock them out. Clearing the + // dedicated kidCategory (not the default category, which terrain also + // uses) keeps the item solid against the bus (for the smash) and the + // terrain (so it lands) while making it a pure ghost to the kids - + // its impact can no longer contribute to ejecting them. (setStatic/ + // setVelocity etc. are untouched; see the rest of this file.) + collisionFilter: { mask: 0xffffffff & ~this.bus.kidCategory }, }); image.setDisplaySize(SMASH_ITEM.displaySize, SMASH_ITEM.displaySize); image.setDepth(1); // same layer as the kids - over the ground, under the bus @@ -125,10 +134,13 @@ export default class SmashItemManager { // see the vendored build). Set on the raw matter body directly: that's the // exact field canCollide reads, and matter-js recomputes pairs every step, // so this takes effect on the very next physics step. The item keeps its - // mask against everything ELSE (terrain, other items, kids), so it still - // lands and rests where it flies - only the bus is exempted. This is what - // makes the bus "drive through" a smashed prop instead of bumping it. - image.body.collisionFilter.mask = 0xffffffff & ~this.bus.busCategory; + // mask against everything ELSE (terrain, other items) so it still lands + // and rests where it flies - the bus and the kids are exempted. This is + // what makes the bus "drive through" a smashed prop instead of bumping + // it. Keep the kid exemption too (see _buildItem): clearing only + // busCategory here would silently re-enable item<->kid collisions after + // the smash. + image.body.collisionFilter.mask = 0xffffffff & ~this.bus.busCategory & ~this.bus.kidCategory; // setStatic(false) (Phaser component, same as in _buildItem) restores // the body's saved real mass/inertia - matter-js stashed them when the