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.

  • State of the input is typically updated only once per frame. In other words, querying the input multiple times in a frame will always get you the same result. Making an engine that does otherwise wouldn't be a wise idea.

State of the input is typically updated only once per frame. In other words, querying the input multiple times in a frame will always get you the same result. Making an engine that does otherwise wouldn't be a wise idea.

    xyz That actually makes a lot more sense and would completely get around the problem. I was thinking of _input() being more of an event callback than something polled with frame processing but as you describe it makes much more sense.

    2 months later

    Sorry to revive this, but, for me it actually is something to look more careful.
    I dont think a player can type that fast that it would make a diference, but in some cases the problem here is a issue.

    Do anyone here knows or played age of empires 3 ? One critic I have with the new age 3 remastered edition is that this new game dont have this functionality and for me it made this game unplayable.
    In the old one, when the game starts, until its loading, you could queue the tasks you want the setters to do, and when the games is lagging also. The new version just dont allow you to do it.

    I am not sure how to fix this in the godot, I think the only way would be to make an new input engine ?

      IceBergyn Or maybe, also, putting everithing in threads, and threat the input as a queue, and the processing of tasks taking command by command from the queue in another thread maybe?

      This may not be the same problem discussed in this topic:

      In my game, I ignore user inputs that are too close together. I use Time.get_ticks_msec() to record the time of an input, and ignore subsequent inputs until 1/2 second has elapsed.

      My intent is to favor tactics over "fast fingers".