Side contact and ending the round
Area3D checks overlap on the floor, including landing beside a hazard already detected in the air.
Hit area
The player's MobDetector uses mask 4, Monitoring and the shape from prefab setup. It detects hazard bodies on layer 3. The capsule handles movement; the area defines the gameplay region for a side hit.
After successful-stomp handling, the complete controller applies this rule: if the player is on the floor, overlapping a live SquashMob calls TakeHit().
Why poll overlaps
BodyEntered alone is insufficient for this rule. A player can enter while airborne, when it is not defeat, then land beside the hazard while remaining inside the area. Another enter event need not occur. The controller therefore reads GetOverlappingBodies() during physics updates and checks current state.
Area lists update on the physics step, not immediately after assigning Position. A newly created or moved object cannot be assumed to have an immediately updated list. This example allows detection on a subsequent physics update.
One defeat
TakeHit() disables Active and clears velocity before emitting Hit. Further overlaps cannot emit it again. EndRun() stops timer and hazards while HUD shows the restart button.
Objects with IsQueuedForDeletion() are ignored. After StartRun(), old hazards can remain in cached overlap lists until actual deletion.
Expected cases
| Situation | Result |
|---|---|
| Falling onto a cube with the qualifying normal | Point and bounce |
| Close side contact on the floor | Round ends |
| Side overlap in the air | No defeat yet |
| Landing beside the same overlapping hazard | Defeat after physics updates |
| Overlap with an old queued cube | Ignored |
For missing hits, check area mask 4, the hazard's numeric layer 4, both shapes and Monitoring. Do not change monitoring or a physics shape directly inside an overlap callback; those changes may require deferral.