- Home /
Jumping not allways registering fix?
Sometimes when I press spacebar the game completely ignores it. It seems to ignore my jump button once every 5-10 jumps, sometimes more than once in a row. It can happen any time, doesn't matter if i'm standing still or if I havn't jumped in a while. Building the game does't fix it. My player object(ball) has sphere collider, meshrenderer, rigidbody, and character controller if it matters.
how can I make jumping respond 100% of the time?
this is in the LateUpdate method:
if (Physics.Raycast (playerT.position, -Vector3.up, 0.6f)) {//is grounded
if (Input.GetKey ("x")) {
rb.velocity = new Vector3 (0.0f, 0.0f, 0.0f);
}
jumpAllowTimer = jumpAllowTime;//can jump 0.2 sec after
} else {//not grounded
jumpAllowTimer -= Time.deltaTime;
}
if(jumpAllowTimer >= 0)//just to make it a bit more forgiving
{
if (Input.GetButtonDown ("Jump")) {
rb.AddForce (0.0f, jump, 0.0f);
}
}
Debug.Log (jumpAllowTimer);
To debug weird behaviour try making a version as simple as possible:
bool jumpAllowed = Physics.Raycast(playerT.position, -Vector3.up, 0.6f);
if (Input.GetButtonDown("Jump") && jumpAllowed)
{
Debug.Log("JU$$anonymous$$PED");
rb.AddForce (0.0f, jump, 0.0f);
}
Try that and check if the log message shows up in the console every time you hit the jump button.
PS: check your timed jump lock jumping gets allowed even after some time in air. The statement jumpAllowTimer >= 0
will be true after some time.
Why are you using -Vector3.up ins$$anonymous$$d of Vecto3.down?
I tried that but sometimes it doesn't jump and the message doesn't happen.
Also tried
if (Input.GetButtonDown("Jump"))
{
count++;
Debug.Log("JU$$anonymous$$PED" + count);
}
Looks like some updates the jump button doesn't trigger. It didn't update the message every time.
Are you sure that your keyboard is ok? $$anonymous$$aybe your spacebar is damaged. Try another key or give a try with another keyboard. Your code should really work...
I have the same issue with my code :( I'm also using jumpAllowTime (got that from Youtube, Eteeski tutorials but the videos were deleted)
Your answer
Follow this Question
Related Questions
Jump Further When Key Is Held Down 1 Answer
When I Hold The Jump Button, Player Will Fly? 2 Answers
Help with player script. 1 Answer
My player is able to double jump, any way to make it a single jump? (C#) 0 Answers
How do I set up my players controller script (How do I change the controls used to move and look) 2 Answers