Make a machine gun fire the same number of shots on any screen
On a fast screen your gun shoots like a toy, on a slow one it sputters, and holding the button after a long pause sometimes gives a sudden burst. Here is how to make the rate honest and keep every bullet where it belongs.
Why this works
A weapon's rate is a promise about time, not about frames. Throwing away the part of a frame left over after each shot ties the rate to the screen, so keep that part, count several shots in one frame if they fit, and place each bullet where it would be by now.
When not to use it
Don't use it for a weapon that fires once per click, charges up, or must wait for an animation to end, like a bolt-action rifle. The shot there is tied to the animation, so let the end of the animation allow the next one.
In the full entry
- What to build, step by step
- Starting values and the reason for each
- 3 common mistakes and the fix
- A diagram of every state
- 24 lines of example code with 4 checks that pass
- How your AI shows you that it works
Say this to your AI
Use the Spielerando entry "Make a machine gun fire the same number of shots on any screen" (read_entry gun-fire-rate-same-on-any-framerate) in my game. Build it step by step, and show me how you checked that it works.Or skip this and connect the MCP: your AI then finds all of this by itself.Connect the MCP