I need to be able to tell the difference via code whether the area a player is in is a peak or a trough, based on the last surface normal, and current surface normal.
Information I have available:
Last surface normal
Last part position
Current surface normal
Current part position
Character velocity ( just in case its useful here… )
Right now I compare the surface normal’s angle relative to directly upward. This was not in anticipation of this problem, it’s just what I already had been doing.
As you can see below, comparing the angles relative to up on both peaks and troughs will yield the same result.
How to measure the change of slope? maybe a combination of finding the player’s movement direction in the XZ Plane and the surface normal similar to this thread, multiple raycasts in a line in front of the player.
Edit: May we know what the purpose of detecting troughs and peaks is though, maybe there are easier alternatives?