Comments and answers for "How to calculate the 3D vector perpendicular to a polygon surface in a specific direction"
http://answers.unity.com/questions/1662376/how-to-calculate-the-3d-vector-perpendicular-to-a.html
The latest comments and answers for the question "How to calculate the 3D vector perpendicular to a polygon surface in a specific direction"Answer by Eno-Khaon
http://answers.unity.com/answers/1662391/view.html
There are multiple ways you can approach this, so here's an example of one of them:
<br> <br>
Because you know your basic "down" vector as well as the normal of the surface you want to walk on <b>and</b> you know your character's basic facing, a few Cross Products can convert your character's facing to align with the ground.
// You mention having both of these already, so I'm glossing over their definitions
Vector3 upVector = (playerTransform.position - asteroidTransform.position).normalized;
Vector3 slopeUpVector = slope.normal;
// This will likely result in the same value as playerTransform.right
// If you've done everything right already, then you won't need these two lines
// However, substituting "player" with "camera" can provide axis-aligned vectors
// for an otherwise non-level camera, so it's good to keep in mind
Vector3 currentForward = playerTransform.forward;
Vector3 playerRight = Vector3.Cross(upVector, currentForward);
// Finally, get the cross product using the player's "right" and the normal of the slope
Vector3 newForward = Vector3.Cross(playerRight, slopeUpVector).normalized;
<sup><i>To note: without any sanitation in place, this can fail when the player's forward direction is 100% parallel to the current up/down vector.</i></sup>Sun, 01 Sep 2019 20:20:42 GMTEno-Khaon