|
|
|
|
|
|
{ |
|
|
|
isJumping = false; //This will stop the reduction to the gravity, which will then quickly pull down the character
|
|
|
|
} |
|
|
|
|
|
|
|
private void UpdateSlide() |
|
|
|
{ |
|
|
|
// if player has to slide then add sideways speed to make it go down
|
|
|
|
if (shouldSlide) |
|
|
|
{ |
|
|
|
movementVector.x += (1f - hitNormal.y) * hitNormal.x * (speed - slideFriction); |
|
|
|
movementVector.z += (1f - hitNormal.y) * hitNormal.z * (speed - slideFriction); |
|
|
|
} |
|
|
|
// check if the controller is grounded and above slope limit
|
|
|
|
// if player is grounded and above slope limit
|
|
|
|
// player has to slide
|
|
|
|
currentSlope = Vector3.Angle(Vector3.up, hitNormal); |
|
|
|
shouldSlide = currentSlope >= characterController.slopeLimit; |
|
|
|
} |
|
|
|
} |