Actor collision detection with offset hitboxes #96

Open
kirsle wants to merge 2 commits from actor-collision into master
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
kirsle added 2 commits 2024-10-21 01:21:37 +00:00
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.
This pull request can be merged automatically.
You are not authorized to merge this pull request.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin actor-collision:actor-collision
git checkout actor-collision

Merge

Merge the changes and update on Gitea.
git checkout master
git merge --no-ff actor-collision
git checkout master
git merge --ff-only actor-collision
git checkout actor-collision
git rebase master
git checkout master
git merge --no-ff actor-collision
git checkout master
git merge --squash actor-collision
git checkout master
git merge --ff-only actor-collision
git checkout master
git merge actor-collision
git push origin master
Sign in to join this conversation.
No reviewers
No Milestone
No Assignees
1 Participants
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.