Thanks for taking the time to answer!
I have considered something similar to this, but there is a couple of problems with it:
-
How can i know where the player is gonna end up in the next frame? If i cant, then that means i need to wait for them to actually be on the ledge and then rubber-band them back to the last valid location, which will feel laggy.
-
If i ingore input when it would move the player to a ledge, this means the player would get “Stuck” or not move at all when moving towards a ledge even in the lightest, which would feel very wrong. If there was a way to make the player just continue to move along the ledge instead of into the ledge (just like it happens when you try to walk into a wall) this wouldn’t happen, but for that i would have to know the angle of the ledge, and solve weird cases in corners
-
doing only one line trace in the center of where the player would be would still let the player get its center right on the ledge by moving with a very small angle of attack towards the ledge, so i would have to do arbatrarily many line traces, but this is not as bad as the other two points.