Everytime I hold down the spacebar, my character slowly floats up. How do I make it so the holding of the spacebar doesnt make him float upward?
//JUMPING SECTION
if(Input.GetKeyDown (KeyCode.Space) && canJump == true)
{
staminaInfo.staminaBar.fillAmount -= 0.10f;
StartCoroutine(“MyMethod”);
}
if(canJump == false)
{
jumpTimer -= Time.deltaTime;
chMotor.jumping.enabled = false;
}
if(jumpTimer <= 0)
{
canJump = true;
chMotor.jumping.enabled = true;
jumpTimer = 0.7f;
}
if(staminaInfo.staminaBar.fillAmount == 0)
{
canJump = false;
chMotor.jumping.enabled = false;
chMotor.movement.maxForwardSpeed = 6;
chMotor.movement.maxSidewaysSpeed = 6;
}
}
IEnumerator MyMethod() {
yield return new WaitForSeconds(0.1f);
canJump = false;
}