- Home /
Others can't jump in my game
I are making a 2d game. And it's works fine on my computer. But when i try to give it to others, then some of them can only jump some few times when they are clicking on the jump button. I think it's something with the framerate, but i'm not sure. The code which checks if the jump button is clicked is in FixedUpdate. Can anyone help me? :) (Have only taken the part of the code which checks the jump button)
void FixedUpdate ()
{
if(Input.GetKeyDown(KeyCode.W) && canStartJump==false && jumpsLeft>0 || Input.GetKeyDown(KeyCode.UpArrow) && canStartJump==false && jumpsLeft>0)
{
jumpsLeft--;
canJump = true;
jumpTimer = 0;
rigidbody2D.velocity = new Vector2(rigidbody2D.velocity.x,ekstraJumpHeight);
}
else if(Input.GetKeyDown(KeyCode.W) && canStartJump==true || Input.GetKeyDown(KeyCode.UpArrow) && canStartJump==true)
{
canJump = true;
jumpTimer = 0;
rigidbody2D.AddForce(new Vector2(0, jumpHeight * 8));
}else if (Input.GetKey (KeyCode.W) && canJump==true && jumpTimer < maxJumpTimer || Input.GetKey (KeyCode.UpArrow) && canJump==true && jumpTimer < maxJumpTimer)
{
jumpTimer+=Time.deltaTime;
rigidbody2D.AddForce(new Vector2(0, jumpHeight));
}else
{
canJump = false;
}
}
Answer by Eric5h5 · Feb 03, 2015 at 04:59 AM
You can't use any input Down or Up events in FixedUpdate. The input events are only true for the single frame they are activated, which may or may not coincide with a FixedUpdate. So input like this must only ever be done in Update (or a coroutine that runs every frame).
Thank you, but now i found the main reason. When you lower the graphic on the game, then the player jumps higher and when you make the graphic better, then the player jumps less. What can be the reason for this? :)
Your answer
![](https://koobas.hobune.stream/wayback/20220613182233im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Unity 2D Top Down Jump 1 Answer
Coyote Time/Ledge Assistance Causes Double Jump 4 Answers
Super Ghouls 'n Ghosts style jumps & double jumps? 1 Answer
Problem with Jump 1 Answer