Ok so I wanted to make a "Pre-Jump" mechanic, where if you press jump slightly before you hit the ground, you will jump as soon as you land.
Code is very simple:
If you press jump button while platform is not on ground - set "PreJump" value to 30
If PreJump is greater than 0 - Subtract 1 from PreJump
If Player is on ground and PreJump is greater than 0 - Jump
This almost always works no problem. Sometimes though, if I press Jump while in the air, not only will the object not jump on landing, but will then not be able to jump at all until the "PreJump" value reaches 0. (Tested in debug mode)
I recreated this in a blank project with just a Player object and ground and it still happens.
I can't seem to force it to happen, and usually have to just spam jump to get it to trigger. Sometimes it feels like holding jump right before landing effects it, but it's hard to tell.
Screencap of code: imgur.com/cNAWFdn
Anybody know what might be happening?