Why your jump sometimes does nothing

You pressed it. The game never saw it.

Why your jump sometimes does nothing

The problem

Reading a press in the physics step.

protected override void OnFixedUpdate(){    if ( Input.Pressed( "jump" ) )        Jump();}

OnFixedUpdate runs on the physics clock, not the frame clock. Some frames it runs twice, some frames not at all.

Why it misses

A press lasts exactly one frame.

Pressed is true for the frame the button went down, and false again after.

Pressed
true for exactly one frame
The physics step
may not land inside that frame
Result
nobody ever reads the press

At 144 FPS with a 50 Hz physics clock, most frames have no physics step at all.

The fix

Read input in OnUpdate. Act on it in physics.

bool wantsJump; protected override void OnUpdate(){    if ( Input.Pressed( "jump" ) )        wantsJump = true;} protected override void OnFixedUpdate(){    if ( wantsJump ) { Jump(); wantsJump = false; }}

OnUpdate never misses a frame, so it never misses a press.

Which clock is which

One is frames. One is physics.

OnUpdateOnFixedUpdate
Runsevery frameon the physics clock
Ratewhatever the PC doessteady
Use forinput, camera, visualsforces, velocity, movement

Anything that lasts one frame belongs on the frame clock.

The rule

Catch input on frames. Spend it on physics.

Pressed, Released
OnUpdate
Held down
either one
Moving a body
OnFixedUpdate

Holding still works, which is why only tapping feels broken.