Romannnnn The _process()
function gets automatically executed each frame, incessantly, 60 times per second. Doing a while loop inside it to test for a state persistency across multiple frames makes no sense.
Instead, you need to determine if the player is on floor or in the air at every individual frame by calling is_on_floor()
, and then set the max horizontal speed according to its true/false return value.
Btw While
is not a keyword in GDScript, whereas while
is. The language is case-sensitive.