GTcreyon / SM63Redux

Code base for Super Mario 63 Redux
https://sm63redux.com
Mozilla Public License 2.0
196 stars 27 forks source link

Player can land inside of slanted fungi #125

Open Kuma-Boo opened 1 year ago

Kuma-Boo commented 1 year ago

Describe the bug If the player collides with a slanted fungus in the right way, the game doesn't register them as on the ground properly. It's not a softlock, as you can get out by holding either left or right.

To Reproduce Go to tutorial 1 room 3. Use the hover nozzle underneath the slanted fungus. Land inside of it.

Expected behavior Mario should either fall to the ground or be snapped to the fungus.

Video of the bug

https://user-images.githubusercontent.com/46894189/228321597-e5440260-2b26-4dd3-986d-00833ada0db7.mp4

System Information

Additional context This can also be performed by walking off the higher side and holding back into the platform.

nyanpasu64 commented 1 year ago

Hypothesis: you hover in tilted mushrooms, because there's code that recognizes when you just barely miss a jump to a ledge above you (Mario's position >= y position of ledge - a bit), and snaps you upwards to the y position of the ledge.

The problem arises when the ledge is slanted, and the code uses the y-position of the center of the ledge, even though the higher side of sloped floors is higher than the center, and needs Mario to be higher to either almost or fully clear it.

The code should detect when you're either just below the y position of your current x position, or (more leniently) your position projected along the normal (perpendicular) vector is just below the plane's surface. Then it should snap you to the y-position at your current x position, or (smaller jump but also moves you horizontally) project your position along the normal to the plane's surface. Afterwards, it may be necessary to eject Mario further upwards, so his entire floor collision points (not just bottom center) are located above the floor.

GTcreyon commented 1 year ago

In general, I think the SafetyNet class should be deprecated and replaced with a player-centered solution using raycasts. SafetyNet is clunky and hard to adapt, and a raycast solution would allow the player to walk up shallow stairs instead of getting stuck.