Actor collision detection with offset hitboxes #96

Merged
kirsle merged 4 commits from actor-collision into master 2026-08-24 03:02:39 +00:00
Owner

This branch attempts to fix actor collision hitboxes when their hitbox is "offset" away from the 0,0 top left coordinate.

Most of the built-in doodads have hitboxes anchored at 0,0 but some (like the Snake and Crusher) are offset - if playing as them, collision bugs may cause clipping through floors or not activating buttons correctly.


Some issues remaining:

  • If playing AS an offset-hitbox character:
    • Solid hitboxes against closed doors and platforms works OK.
    • Button InHitbox (overlap) checks do not fire (buttons won't press).
  • If playing with a non-offset character (e.g. boy.doodad)
    • Solid hitboxes work and Buttons will press correctly.
  • Both types of player hitboxes:
    • When touching a static object such as the Start Flag which has an offset hitbox of its own: the Start Flag will creep up the level on its Y axis when touched before it settles and won't move.

373028a166

Play as Boy:

  • Start Flag (offset) creeps upwards on collision
  • test-hitbox doodad solid collision OK
  • No 'sticking' on sides of solid doodads (can still fall down): OK
  • Button interaction OK
  • DOES NOT reliably trigger Crumbly Floor (0,0,98,11) (OnTop regression?)

Play as Mario (0,32,32,32):

  • Start Flag creeps upwards on collision
  • Button doesn't interact normally: its active hitbox triggers ~32px below where it should
  • Jank hitbox with closed electric doors (0,0,34,76): can clip inside and get stuck
  • test-hitbox doodad solid collision OK
  • Crumbly floor: hit or miss whether he lands on (doesn't trigger it), or triggers it but teleports straight through
This branch attempts to fix actor collision hitboxes when their hitbox is "offset" away from the 0,0 top left coordinate. Most of the built-in doodads have hitboxes anchored at 0,0 but some (like the Snake and Crusher) are offset - if playing as them, collision bugs may cause clipping through floors or not activating buttons correctly. --- Some issues remaining: * If playing AS an offset-hitbox character: * Solid hitboxes against closed doors and platforms works OK. * Button InHitbox (overlap) checks do not fire (buttons won't press). * If playing with a non-offset character (e.g. boy.doodad) * Solid hitboxes work and Buttons will press correctly. * Both types of player hitboxes: * When touching a static object such as the Start Flag which has an offset hitbox of its own: the Start Flag will creep up the level on its Y axis when touched before it settles and won't move. --- # 373028a16693ed2fccb0f867a6cbb1ee1009c308 Play as Boy: * Start Flag (offset) creeps upwards on collision * test-hitbox doodad solid collision OK * No 'sticking' on sides of solid doodads (can still fall down): OK * Button interaction OK * DOES NOT reliably trigger Crumbly Floor (0,0,98,11) (OnTop regression?) Play as Mario (0,32,32,32): * Start Flag creeps upwards on collision * Button doesn't interact normally: its active hitbox triggers ~32px below where it should * Jank hitbox with closed electric doors (0,0,34,76): can clip inside and get stuck * test-hitbox doodad solid collision OK * Crumbly floor: hit or miss whether he lands on (doesn't trigger it), or triggers it but teleports straight through
When an actor's Hitbox doesn't begin at 0,0 the collision checks between
boxes is buggy. Current progress:

* Player is a 32x64 size sprite with a hitbox of 0,32 32x32 (bottom half)
* Landing onTop works
* Hitting onBottom works
* Bug: colliding from the side currently pushes the player 32px down
  into the floor. With non-offset doodads walking sideways into e.g. a
  locked door halts the X and Y movement until you let go, but offset
  doodads get pushed down mysteriously.
Clean up and improve the between-actors collision code:

* Give names to the A, B tuples from BetweenBoxes and call them the stable and
  mover doodads. All ops are from the perspective of the stable (A) box in
  relation to the mover (B).
* Replace the map[*Actor]*Actor collision struct to one that supports arrays of
  colliding actors, enabling one actor to post OnLeave events correctly when it
  overlapped several actors at once.
* Possibly improve on some of the collision bugs along the way.

Some issues remaining:

* If playing AS an offset-hitbox character:
    * Solid hitboxes against closed doors and platforms works OK.
    * Button InHitbox (overlap) checks do not fire (buttons won't press).
* If playing with a non-offset character (e.g. boy.doodad)
    * Solid hitboxes work and Buttons will press correctly.
* Both types of player hitboxes:
    * When touching a static object such as the Start Flag which has an offset
      hitbox of its own: the Start Flag will creep up the level on its Y axis
      when touched before it settles and won't move.
* With help from Claude Code, finally fix collision detection bugs
  involving actors who have hitboxes offset from the 0,0 corner:
  - Buttons and switches not activating when touched by an offset-hitbox
    character.
  - Bugs with solid hitboxes between doodads when one has an offset
    hitbox.
kirsle merged commit 71a6037ac1 into master 2026-08-24 03:02:39 +00:00
kirsle deleted branch actor-collision 2026-08-24 03:02:39 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
SketchyMaze/doodle!96
No description provided.