Skip to content

Instantly share code, notes, and snippets.

@jawinn
Created August 3, 2015 06:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jawinn/120abdb46f898e1318d1 to your computer and use it in GitHub Desktop.
Save jawinn/120abdb46f898e1318d1 to your computer and use it in GitHub Desktop.
Simple Method - Slope Under Player
private float groundSlopeAngle = 0f; // angle
private Vector3 groundSlopeDir;
// The controller hits a collider while performing a Move.
void OnControllerColliderHit (ControllerColliderHit hit)
{
Vector3 temp = Vector3.Cross(hit.normal, Vector3.down);
groundSlopeDir = Vector3.Cross(temp, hit.normal);
groundSlopeAngle = Vector3.Angle(hit.normal, Vector3.up);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment