- Home /
Checking slope angle the object is standing on?
How can I get the angle of the slope an object is standing on?
Thanks
Answer by Jesse Anders · Mar 06, 2011 at 01:32 AM
The angle can be computed from the collision normal (assuming you have it available). For example, if +y is up, the angle can be computed as follows (untested):
float angleInRadians = Mathf.Acos(Mathf.Clamp(normal.y, -1f, 1f));
Sorry, this is probably a really dumb question. What does the normal variable contain?
A normal is a vector that is at a right (90 degrees) angle from the plane.
http://upload.wikimedia.org/wikipedia/commons/f/f6/Surface_normal.png
All the blue arrows are normals for the point they're co$$anonymous$$g from (immagine each point is part of an invisible STRAIGHT plane). So if you have an "up" direction for the slope (the collision normal), you can calculate the angle.
Your answer
![](https://koobas.hobune.stream/wayback/20220613111530im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Camera direction depending on targets slope (X axis) 0 Answers
How to change an angle of object with Rigidbody2D in a specific range? 0 Answers
How can I detect the angle of the platform the player is on? 1 Answer
Why am I not getting an angle in degrees from aTan? 1 Answer
Slope angle fix 0 Answers