Hi there! I was wondering how to determine whether an object is falling or just going down a slope. Here's what I mean: if my character walks off a ledge, I want to slow down their lateral movement speed and make them fall through the air. If they're going down a slope , I want to keep their movement speed fast, just with their position lowered to match the stage's floor. I also don't want the player to slide down slopes unless they're too steep (say, greater than 60 degrees from being horizontal).
I already have character-to-stage collision implemented, and I tried one algorithm to handle gravity already. What I did was cast a ray from the bottom of the character's feet into the floor to find the nearest point on the floor below the character, then created a right triangle. Point 1 was at the character's position last frame, point 2 at the floor below on the current frame, and the right angle straight above the point 2. I then determined if the angle at point 1 was greater than 60 degrees, and made them fall if it was.
This worked at high framerates, but at low framerates the character would ignore high ledges, thinking it went down a slope when didn't, because the character would go so far away from the ledge in one frame that the angle would turn out to be something like 45 degrees, and the character would zip straight to the floor. So that algorithm kind of goes out the window, seeing as it doesn't work if your computer's slow.
tl;dr, How can I discern whether my character is falling off a ledge or walking down a slope?