$ ./guess_the_languageGame Dev
Game Dev · hard · #273

Why are some jump presses ignored?

void FixedUpdate() {
  if (Input.GetKeyDown(KeyCode.Space)) Jump();
}
  1. GetKeyDown only works in menus
  2. FixedUpdate may not run that frame
  3. Space is reserved by the physics engine
  4. Jump() runs before input is read
GetKeyDown is true only for the rendered frame of the press; if no fixed step runs that frame, the press is missed. Read input in Update and apply it in FixedUpdate.
Play Game Dev ▸