- Home /
The rotation of an object in relation to ground
Hello, I'm making a little ski game and I want to have crash detect. So if you land too sideways it will trigger the crashing animation. How can I read what the rotation of the character is in relation to the normals?
Let's say the crash tolerance is 45 degrees. The character is rotated 45 degrees but the ground is also at a 45 degree slope meaning the sum of the two would be 90, making the character land on his side. Here's a little diagram of what I mean:
PS he's not pissing blood, that's a raycast :)
Answer by Berenger · Jun 11, 2012 at 06:18 PM
OnCollisionEnter (when the player touches the slope) provides you the normal at the impact through CollisionInfo.ContactPoint. I suggest you calculate the dot product between that normal and transform.up (of the player). If it is > 0.7 for instance, the landing is safe. Reminder : angle = acos(dotproduct).
Or you could use Vector3.Angle.
PS : Awesome drawing :p
$$anonymous$$an that's fun! I'll be sure to show you my game once it's done
Your answer
Follow this Question
Related Questions
Raycast Normal in Local Rotation? 1 Answer
Help with getting buildings blocks to appear on hit object's normals 1 Answer
How to get to know a mesh' faces normals? 0 Answers
How i can a normal vectors? 3 Answers
RaycastHit.normal Problem 1 Answer