- Home /
How to detect ground slope angles in 3d?
Hey, I am looking to detect the ground slope angles to limit movement after certain extent. Some people were saying I should use:
Vector3.Angle(hit.normal, Vector3.up);
But it never gives me any useful value and any rotation ruins the result completely.
Perhaps there's some miscommunication, then. The angle between (Raycast)hit.normal and Vector3.up assumes that gravity is pulling directly down. Therefore, the Angle between them should be the slope of the ground (where 0 degrees is flat ground).
In that regard, what sort of "useful value" are you looking for in particular?
By useful value, I actually mean a close enough accurate angle. With Angle(hit.normal, Vector3.up), I am getting anywhere from 10 to 80 on completely flat ground.
Answer by Zee-Play · Sep 21, 2018 at 02:22 PM
You could just do a raycast in the direction you're moving to and see how high it hit compared to your current Y position :)
Hope you like Ms paint