While building a small turn-based multiplayer golf prototype, I hit a bug that completely soft-locked the game.
The ball would roll, slow down… and never actually stop.
Visually, it looked stationary.
Numerically, it was still moving.
In a turn-based multiplayer game, that’s fatal - the turn can’t advance unless the ball fully stops.
What went wrong
I was applying friction every update, assuming velocity would eventually reach zero.
It didn’t.
Floating-point math meant the velocity just kept approaching zero forever. The game thought the ball was still moving, so the turn never ended.
The fix
I moved all physics logic into the authoritative game logic and added a hard “snap-to-zero” threshold.
Once the ball’s speed dropped below a small value, I forced it to stop and advanced the turn.
One line of logic fixed the entire multiplayer flow.
Takeaway
If your game logic depends on something ending, you can’t rely on “almost zero.”
You need to define what zero actually means.
I wrote a deeper postmortem about building this game in a week - including procedural generation, multiplayer decisions, and what I’d do differently next time - here:
Top comments (0)