[Tooltip("Represents how fast gravityContributionMultiplier will go back to 1f. The higher, the faster")]publicfloatgravityComebackMultiplier=15f;
[Tooltip("The maximum speed reached when falling (in units/frame)")]publicfloatmaxFallSpeed=50f;
[Tooltip("Each frame while jumping, gravity will be multiplied by this amount in an attempt to 'cancel it' (= jump higher)")]publicfloatgravityDivider=.6f;
[Tooltip("Adjust the friction of the slope")]publicfloatslideFriction=0.3f;
privatefloatgravityContributionMultiplier=0f;//The factor which determines how much gravity is affecting verticalMovement
privateboolisJumping=false;//If true, a jump is in effect and the player is holding the jump button
privateVector3hitNormal;// ground normal
privateboolshouldSlide;// Should player slide?
//Raises the multiplier to how much gravity will affect vertical movement when in mid-air
//This is 0f at the beginning of a jump and will raise to maximum 1f
if(!characterController.isGrounded)
//Calculate the final verticalMovement
if(!characterController.isGrounded)
{
//Less control in mid-air, conserving momentum from previous frame
movementVector=inputVector*speed;
}
}
// if player has to slide then add sideways speed to make it go down