Gaffer On Games
gafferongames.com · Personal blog · on HN since 2009
Glenn Fiedler writes about game networking, physics integration, fixed timesteps, and floating point determinism for game programmers.
What HN saysCommenters call it a must-read for game networking and recommend his articles on UDP, cheating, and netcode.
159HN people shared it
112linked it in comments
65stories submitted
2.0Kstory points
4 months agolast shared
2009people per year2026
Most-shared posts
- 1Fix Your Timestep17 people · 136 points · first shared 2017 · 54 comments on HN
- 2Gaffer on Games16 people · 2 points · first shared 2014 · discussion on HN
- 3What every programmer needs to know about game networking (2010)14 people · 150 points · first shared 2010 · 24 comments on HN
- 4Floating Point Determinism14 people · 50 points · first shared 2010 · 19 comments on HN
- 5Fix Your Timestep14 people · 24 points · first shared 2009 · 5 comments on HN
- 6Networking for Game Programmers12 people · 1 points · first shared 2011 · 1 comments on HN
- 7What Every Programmer Needs to Know About Game Networking7 people · 5 points · first shared 2019 · discussion on HN
- 8Game Physics – Integration Basics7 people · 1 points · first shared 2010 · discussion on HN
- 9UDP vs TCP6 people · 460 points · first shared 2010 · 190 comments on HN
- 10Is it possible to make floating point calculations completely deterministic?6 people · 5 points · first shared 2017 · 1 comments on HN
- 11Why can't I send UDP packets from a browser?6 people · 1 points · first shared 2017 · 1 comments on HN
- 12Launch of libyojimbo5 people · 17 points · first shared 2016 · discussion on HN
- 13Never trust the client4 people · 365 points · first shared 2016 · 152 comments on HN
- 14Introduction to Networked Physics4 people · 14 points · first shared 2015 · 1 comments on HN
- 15Deterministic lockstep4 people · first shared 2018
What HN people wrote when they linked it
jconley · 2021-11-09
Of course if someone wants to cheat at this they can, even with those deterrents. It's a fun cat and mouse game for the cheater, less so for the developer. :) I'd recommend reading Greg Gaffer's articles. He gets into a lot of detail on this in networked multiplayer games. https://gafferongames.com
hesdeadjim · 2021-10-26
Highly recommend Glen Fiedler's articles for this topic.
https://gafferongames.com/
drawkbox · 2021-02-03
When you get to game networking Gaffer On Games is a must read. Efficient game networking layers are all about that UDP [2] and reliable UDP [3]. When web games were huge it would have been pure gold to have WebRTC with built in UDP, NAT/punchthrough etc.
[1] https://gafferongames.com/
[2] https://gafferongames.com/post/reliability_ordering_and_congestion_avo…
[3] https://gafferongames.com/post/reliable_ordered_messages/
qwery · 2026-07-02
PhysX itself (assuming Unity still uses PhysX, but any major physics engine will be the same) is unlikely to be your problem, although it is possible that Unity compiles it with undesirable optimisations, or some aggressive multithreading strategy, etc.
In any case, it's quite likely that the physics simulation is not being initialised with identical state on each instance, so the physics engine -- even if it claims to be deterministic -- cannot be expected to arrive at the same solution across instances.
From the scripting layer atop Unity (et al.) you are essentially out of luck. You don't have the requisite control/access to guarantee the simulation input is consistent.
To expand on the "quite likely" variance in the simulation input, there's an unending list of possibilities, so just a couple of points: Unity is really really big and complicated.
The physics engine in Unity is not primarily there to be a FEATURE: physics engine. It's a general purpose collision system, and it's fundamental to Unity's whole world/scene/components. It's always running. Stuff that has nothing to do with what you see as your simulation can affect your simulation.
My unopinionated advice is: read Glenn Fiedler's classic networked physics articles[0].
My opinionated advice is: you're making a game where the physics is the whole game. It's also a very nicely contained problem space. Write your own physics simulation. It's gameplay code. Also, typical rigid body physics engines certainly can…
insraq · 2025-04-09
Just want to chime in that although this comment is a bit harsh, it does hold a lot of truth. As a game netcode engineer, most of my time is spent on latency hiding techniques and its consequences (for example, we use rollback netcode and lots of efforts are spent on minimizing visual/sound glitches when mispredict, rollback and reconcile). There are lots of middleware that help with this (eg. Photon, SnapNet, etc) but in general there's no silver bullet - it's highly gameplay specific. Even for the same game, the solution can vary depending on different trade-offs (i.e. budget, correctness/anticheat).
As to how to store the game state in memory, it's usually not something that needs much thinking: it's simply done the same way (or similar) as the game's client code. After all, netcode is mostly about efficient state replication and this saves CPU time when replicating it across clients - and gives more CPU time for minimizing bandwidth (like delta encoding, quantization, etc). If you want, you can utilize some techniques like ECS to optimize for CPU cache locality, but it affect gameplay code a lot and would need to get the whole team onboard.
Also, I just noticed the username "gafferongames" - Glenn's blog[1] has been a must-read for netcode engineers. It helped me a lot when I started working on netcode in the 2010s
[1] https://gafferongames.com/
Thaxll · 2024-11-23
One of the best: https://gafferongames.com/
spacechild1 · 2025-11-07
Just wanted to say that I really appreciated your articles about game networking and game physics (https://gafferongames.com/)!
nightowl_games · 2023-12-27
This one's good but pretty advanced. We haven't implemented a lot of these techniques in our games. This is a great starting point:
https://gafferongames.com/post/introduction_to_networked_physics/
larmstrong · 2023-12-20
I really like Gaffer on Games. I haven’t found a lot of good content that goes into the nuts and bolts of net code like he does.
https://www.gafferongames.com/
10000truths · 2022-05-28
Glenn Fiedler’s Gaffer on Games is a worthwhile read for anyone who wants to dive into the technical details of networked physics:
https://gafferongames.com/categories/game-networking/
lodi · 2021-08-26
https://gafferongames.com/post/state_synchronization/
Also search for "game networking" + the following:
- state replication
- dead reckoning
- client side prediction
- networked physics
jbluepolarbear · 2021-07-07
Networking games is hard. It’s what I do for work and it’s an iterative process.
If you’re interested in the subject of physics and netcode I’d recommend: https://gafferongames.com/post/introduction_to_networked_physics/
If your want a very deep dive and very technical, I’d recommend: https://fabiensanglard.net/doom3_documentation/The-DOOM-III-Network-Ar…
A lot of good resources at the bottom of the pdf too.
modernerd · 2019-12-25
ncallaway · 2019-06-13
I've done a small amount, but mostly as hobbyist stuff.
If you haven't looked at it already, Glen Fiedler has a great series on game networking on his Gaffer on Games blogs that covers a lot of those topics in ways that were really helpful for my implementations. https://gafferongames.com/tags/networking/
It looks like his site is down, but it's also available on the internet archive: https://web.archive.org/web/20190405204744/https://gafferongames.com/t… It's all fairly high-level stuff, and I'm sure it mostly just retreads ground that you're familiar with, but I thought the explanations were all super-clear and helped crystallize a lot of thoughts that I already had but hadn't focused that well.
binarycrusader · 2019-01-27
Glenn Fiedler gives the best solution to this:
https://gafferongames.com/post/fix_your_timestep/
I’ve had a great experience so far following Glenn’s suggested solution.
AgentME · 2018-07-29
Some games do it differently, but evmar's advice matches recommendations that I've seen for game engines[0].
[0] https://gafferongames.com/post/fix_your_timestep/
60654 · 2018-05-20
Big book being written right now with beta chapters available:
http://ithare.com/contents-of-development-and-deployment-of-massively-…
Also this site has a nice collection of very widely known blog posts on networking for gamedevs:
https://gafferongames.com/
bschwindHN · 2017-08-21
Don't worry, it hasn't been lost by game developers in the professional space. The article is presumably from a web developer implementing their first game. No offense meant by that statement, but if you're reaching for Socket.io (or even TCP/IP) for a real-time multiplayer game then you're probably going to have a bad time.
Thankfully we have free resources from professionals in the industry to keep us on the right track:
https://gafferongames.com/
fenomas · 2017-04-06
Variable timesteps have their own host of problems. Considering the target and scope of TFA I think best practices are beside the point, but your suggested replacement is bad practice as well.
The "right thing to do" in most games is to integrate at fixed timesteps that are decoupled from rendering. But this can be tricky to get right, and would require another article to explain [0]. Considering all that, the article's implementation is fine!
[0] Except that the definitive article has already been written, that is:
http://gafferongames.com/game-physics/fix-your-timestep/
ewjordan · 2017-04-06
If you tie the frame rate to the physics step, then yes - that will be true for pretty much any physics engine.
The classic advice here is http://gafferongames.com/game-physics/fix-your-timestep/
jshmrsn · 2017-03-29
While we're sharing network programming guides, the Gaffer on Games guide on multiplayer networking is another great read http://gafferongames.com/networking-for-game-programmers/
man5quid · 2016-12-27
http://gafferongames.com/networking-for-game-programmers/what-every-pr…
A great series for you to read.
tl;dr
Udp is good.
client to client sessions are terrible over the internet.
ook · 2016-07-07
And Glenn Fieldler has an excellent series of articles on his blog:
http://gafferongames.com/networking-for-game-programmers/
http://gafferongames.com/building-a-game-network-protocol/
http://gafferongames.com/networked-physics/introduction-to-networked-p…
yarvin9 · 2015-09-19
It seems clear that if we hadn't inherited a bunch of irreproducible languages and/or instruction sets from the 20th century, no one would bother creating a new one. There are certainly some ways to get optimization advantages from underspecified computation, but especially in a networked world this win is outweighed by the problems it causes.
When you use irreproducible floating-point, you're essentially treating your CPU as an analog computer. For a subset of very specialized numerical applications, this is probably okay. For any kind of integration with interesting, non-numerical system software (let alone scientific publishing!), it's a disaster.
I always recommend this link on FP determinism: http://gafferongames.com/networking-for-game-programmers/floating-poin…
falcolas · 2015-08-04
Sounds like the same problems that have been encountered (and mostly solved) in many different online videogames. Might be worth investigating how they solved these problems as well, since their solutions will be much more practical than theoretical.
http://gafferongames.com/networking-for-game-programmers/
pp19dd · 2014-11-25
Entire server is 403'd: http://www.gafferongames.com/
Rather puzzling. Traffic strategy?
kaoD · 2014-09-05
Sounds fun and I would definitely play with my friends :)
Add touch controls for mobile devices if possible (check PewPew for a similar movement mechanic) and you got yourself a pretty fun mobile game. I'm not sure if mobile browsers would be up to the task though, just throwing random ideas.
Does Construct2 include networking and lag compensation? It's hard to achieve smooth gameplay over the internet, especially for fast-paced games like this one. Check [1] for a great resource on networking.
I have some experience on game networking. Feel free to contact me at (el + my HN username) at gmail if you need some help.
[1] http://gafferongames.com/networking-for-game-programmers/
throwawaykf · 2013-11-17
Another good read on game networking:
http://gafferongames.com/networking-for-game-programmers/
flyosity · 2011-04-08
Here's another great game physics reference by Glenn Fiedler. It's a must-read for beginner (and not-so-beginner) game programmers and has helped me immensely.
http://www.gafferongames.com/game-physics/
daredevildave · 2010-10-29
They might want to switch that to the UDP server ( dgram )
Networked games over TCP is not usually recommended: http://gafferongames.com/networking-for-game-programmers/udp-vs-tcp/