- Home /
Question by
Biscuit_Mama · Oct 13, 2021 at 07:30 PM ·
charactercontrollerjumpingfirst-person-controller
Character Controller jump doesn't work for some reason?
So I'm making a character controller script and I'm currently at jump but can't get it to work for some reason. I can get a Debug.Log command to pass from quite about any point in the script, so the issue shouldn't be that the code doesn't go through but I'm still at a complete loss.
The only way I can get it to somewhat work, is by changing the GetKeyDown into GetKey, but the jump is really inconsistent then. Also the air timer keeps increasing and only resetting randomly when I'm moving/jumping. If anyone might know what the issue I'll be very thankful
protected virtual void HandleJump()
{
if (Input.GetKey(KeyCode.Space))
{
velocity.y = jumpForce;
previouslyGrounded = true;
isGrounded = false;
}
}
protected virtual void ApplyGravity()
{
if (characterController.isGrounded)
{
inAirTimer = 0f;
velocity.y = -stickToGroundForce;
HandleJump();
}
else
{
inAirTimer += Time.deltaTime;
velocity += gravityMultiplier * Time.deltaTime * Physics.gravity;
}
}
Comment
Have you tried increasing your jumpForce to a crazy high amount? Could be that your force is not strong enough. Or conversely, the mass of your character is too high
Your answer
![](https://koobas.hobune.stream/wayback/20220613044144im_/https://answers.unity.com/themes/thub/images/avi.jpg)