Imagine coding a double jump. When reading the jump input, if in the air, if hasDoubleJumped
is false, set hasDoubleJumped
to true and apply extra jump velocity. Because if x == false: x = true
isn't an atomic operation, someone inputting the jump fast enough (probably faster than humanly possible) could get multiple jump velocity additions in before the game logic would detect they had already double jumped.
Looking through Godot documentation, it doesn't look like there is access to interlocked addition (an atomic mechanism to set a value and get the value it was at before the addition). Is this a thing we just don't worry about in game dev? I imagine we don't and just let the TAS people have fun trying to break the physics but idk and I haven't found mention of this elsewhere.