Ledge Snap
Ledge Snap
Short explanation of what it does
If you want to jump on a platform and you almost but not really make it on top of the platform, this mechanic will place you on top of that platform.
Also, whenever you try to jump off a platform, you will still have a small time frame to jump instead of immediately falling off the platform.
How it works
This code constantly checks from all grabbable points in the level what grabbable point is closest to the player, so it knows where you can do a ledge snap.
When the player is within the range of the grabpoint then we check if the player is jumping to or from the grabpoint. If the player is jumping to the grabpoint then the player will be set on top of the grabpoint but, if the player is jumping from the grabpoint then all it does is give the player extra range to still be able to jump.