When Mario’s cylindrical hitbox overlaps an object’s hitbox, SM64 does not immediately react—it records which interaction types were collided this frame in a bitmask, then dispatches a dedicated handler function for each type once per frame. This deferred dispatch model, combined with theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/n64decomp/sm64/llms.txt
Use this file to discover all available pages before exploring further.
oInteractStatus field that objects set as acknowledgement, allows collectibles, enemies, hazards, doors, and environmental triggers to all share the same collision detection pass while handling results completely differently.
Interaction type constants
Each object declares which kind of interaction it participates in by settingoInteractType (rawData slot 0x2A). The values are single-bit flags defined in src/game/interaction.h:
Interaction subtypes
SeveralINTERACT_* flags share a second bitmask field oInteractionSubtype that further qualifies behavior:
collidedObjInteractTypes bitmask
Bothstruct Object and struct MarioState carry a collidedObjInteractTypes field:
oInteractType bits are ORed into Mario’s collidedObjInteractTypes. The object itself also accumulates which interaction types it was contacted by into its own copy.
The handler dispatch table
mario_process_interactions() iterates the static handler table, checking each registered type against Mario’s collidedObjInteractTypes:
mario_process_interactions():
- Each type is consumed from the bitmask once handled (
&= ~interactType), so each type is processed at most once per frame. - The guard
!(object->oInteractStatus & INT_STATUS_INTERACTED)prevents double-collecting an already-taken object. - If a handler returns
TRUE(e.g. a damage handler that changes Mario’s action), the loop breaks immediately.
ObjectHitbox geometry
The interaction zone is a vertical cylinder defined by four fields instruct Object:
obj_set_hitbox() from an ObjectHitbox struct:
oInteractStatus result field
After a handler runs it communicates back to the object throughoInteractStatus (rawData slot 0x2B):
oInteractStatus every frame to detect that an interaction occurred. For example, the coin checks INT_STATUS_INTERACTED to know when to spawn sparkles and delete itself:
Mario’s attack types
When Mario is in an attacking state,determine_interaction() sets one of these attack constants in the interaction result:
u8[][6]) keyed by these values to determine the response—knockback, squish, or no effect.
Complete walkthrough: coin collection
Setup — ObjectHitbox
During
bhv_yellow_coin_init, the coin calls obj_set_hitbox(o, &sYellowCoinHitbox). This writes INTERACT_COIN into oInteractType, 100 into hitboxRadius, and 64 into hitboxHeight. The coin is now detectable.Collision detection
Each frame the collision system tests Mario’s capsule against every active object. When Mario steps inside the coin’s cylinder, the coin’s
oInteractType (INTERACT_COIN) is ORed into both mario->collidedObjInteractTypes and the coin’s own collidedObjInteractTypes. The coin is also stored in Mario’s collidedObjs[] array.Handler dispatch
mario_process_interactions() finds INTERACT_COIN set in m->collidedObjInteractTypes. It calls mario_get_collided_object(m, INTERACT_COIN) to retrieve the coin pointer, then invokes interact_coin(m, INTERACT_COIN, coinObj).Complete walkthrough: star collection
Stars useINTERACT_STAR_OR_KEY. The handler is more complex because collecting a star typically ends the level:
INT_STATUS_INTERACTED and plays its collect animation before the level transitions.
Interaction type quick reference
Collectibles
INTERACT_COIN — coins, blue coins, red coinsINTERACT_STAR_OR_KEY — Power Stars and castle keysINTERACT_CAP — Wing Cap, Metal Cap, Vanish CapINTERACT_WATER_RING — Manta Ray rings (heal)Hazards
INTERACT_DAMAGE — generic enemy contact damageINTERACT_BOUNCE_TOP — enemies killed by jumping on topINTERACT_FLAME — fire sources (burn damage)INTERACT_SHOCK — Amp electric zapINTERACT_BULLY — shove physics interactionEnvironment
INTERACT_DOOR — regular doorsINTERACT_WARP_DOOR — doors that warp to another areaINTERACT_WARP — invisible warp triggersINTERACT_CANNON_BASE — cannon entranceINTERACT_TORNADO — Tweester spiralINTERACT_WHIRLPOOL — underwater whirlpoolActions
INTERACT_GRABBABLE — objects Mario can pick up and throwINTERACT_POLE — climbable poles and treesINTERACT_HOOT — Hoot the owl (grab to fly)INTERACT_TEXT — signs and NPCs (dialog trigger)INTERACT_KOOPA_SHELL — rideable shell