How can I disable a character from climbing the side of a mountain (like greater than 60 degrees)? With the CharacterController I can set the slope limit which disables running up the mountain, but I need to not allow them to jump up it either. So how could I use the slope limit for a jump (or something similar), or make the character slide down if the incline is too great?
Made a method function TrackGrounded which was passed a Collision.
void TrackGrounded(Collision col)
{
float minimumHeight = capsule.bounds.min.y + capsule.radius;
foreach (ConactPoint c in col.contacts)
{
if (c.point.y < minimumHeight)
{
float slopeAngle = (-c.normal.y + 1.0f) * 100.0f;
if (slopeAngle < slopeLimit)
{
// grounded is used in the FixedUpdate callback
grounded = true;
}
}
}
}
void FixedUpdate()
{
if (grounded)
{
// Get input status and do player movement...
}
// I used custom gravity here
}
Might have to play around with some of those values and mess with other things (like if your world can get you stuck between two slopes)… but hope that helps.