Better isGrounded Solution / Detect angle of ramp

The player, (represented by a character controller) moves by an amount of Vector3 playerVelocity on each frame. This is influenced by the following two lines of code:
_
Vector3 collisionDifference = collision.normal * Vector3.Dot(playerVelocity, collision.normal);
_
playerVelocity -= collisionDifference;
_
Combined with the constant downwards force of gravity and the player will begin to slide down a ramp, in the same fashion that a ball rolls down slopes. Makes sense in terms of physics, but in real life we have two feet rather than a rounded capsule which can’t rotate. Of course, if the friction isn’t strong enough, we still slide downwards, but my predicament lies in how I can check whether or not the player is standing on an appropriate surface for them to slide down.
_
How can I check what the angle of a surface below a CharacterController is? I need to be able to differentiate between flat ground and anything above a 35 degree angle- I want the player to slide down slopes above 35 degree, but my isGrounded function uses a checkbox to avoid some corner cases with player immobility, and I’d like to be able to see what the angle of surfaces beneath the player are.

To make things easy for you, Character Controller has a handy property called OnControllerColliderHit(), which take a parameter of type ControllerColliderHit and you can easily take the angle of of collision with the handy normal property.

float hitAngle;

void OnControllerColliderHit(ControllerColliderHit hit)
{
  hitAngle = hit.normal;
}

a nice solution would obviously be to put you sliding code into this method…but you can take that directly to the update method if you don’t want more than one slope affecting the player…Hope this helps