private bool handleHorizontalSlope( ref Vector3 deltaMovement, float angle )
{
// disregard 90 degree angles (walls)
if( Mathf.RoundToInt( angle ) == 90 )
return false;
// if we can walk on slopes and our angle is small enough we need to move up
if( angle < slopeLimit )
{
// we only need to adjust the deltaMovement if we are not jumping
// TODO: this uses a magic number which isn't ideal!
if( deltaMovement.y < jumpingThreshold )
{
// apply the slopeModifier to slow our movement up the slope
var slopeModifier = slopeSpeedMultiplier.Evaluate( angle );
deltaMovement.x *= slopeModifier;
// we dont set collisions on the sides for this since a slope is not technically a side collision
// smooth y movement when we climb. we make the y movement equivalent to the actual y location that corresponds
// to our new x location using our good friend Pythagoras
deltaMovement.y = Mathf.Abs( Mathf.Tan( angle * Mathf.Deg2Rad ) * deltaMovement.x );
_isGoingUpSlope = true;
collisionState.below = true;
}
}
else // too steep. get out of here
{
deltaMovement.x = 0;
}
return true;
}