- Home /
Question by
alexjhones286 · Dec 02, 2019 at 07:55 PM ·
1st person
In my game the "W" button or "up arrow" button or "space" button makes my doll jump. If I squeeze two of them at the same time my doll jumps twice the force. I don't want this to happen, can anyone help me?
if (Input.GetKeyDown(KeyCode.Space) || Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.UpArrow))
{
myRigidbody.AddForce(new Vector2(0, jumpForce));
}
Comment
Answer by Casiell · Dec 02, 2019 at 09:09 PM
Looking at this code I can tell you that if you press any of those keys twice your character will jump twice. In fact you can jump as much you want based on this code only.
You have to make some kind of check for whether or not your character is currently jumping.
Also you "press" a button, not "squeeze" it.
Your answer
![](https://koobas.hobune.stream/wayback/20220612215612im_/https://answers.unity.com/themes/thub/images/avi.jpg)