Physics Networking: How can I properly do it to my 2D game?

default Godot physics are not deterministic. That means if you give a fixed input to multiple godot physics clients, you will not get an expected output. This is a problem all online games have (unless you use something like SGPhysics2D or Rapier )

The solution is quite simple. Only the host does the physics, and its physics’ results override to all clients. So there is essentially only 1 physics simulation. What the clients receive is the result, aka what position they should have.

tl;dr: Only the host has physics, the clients receive the positions (not the velocities)

The above will result in jittery movement if you apply it as-is, so every game has a simple snapshot system, which essentially stores the last 3 snapshots (last 3 physics states received from the host), and lerps between them. That’s how you get smooth motion, even though there is latency.

Related link: Source Multiplayer Networking - Valve Developer Community

4 Likes