Moondog, day 1 (15 Oct): chat, a real login, and the hunt for the jitter

Moondog is the MMO I'm building: a C# game server on Godot, a Godot client, a web portal for accounts and an admin site. The first commit went in late on the 14th (the server stack and a night theme for the web pages). The 15th was the first real day, and most of it went into one question: why does walking around feel bad?

Chat and login

The first few hours were plumbing. Chat moved into its own scene, then took several commits to route RPCs properly, because Godot matches RPCs by node path and the client and server trees didn't match. I added chat history on join, player name labels that fade with distance, and remote players that move by interpolating between snapshots instead of teleporting.

The client got a proper login screen that exchanges portal credentials for a play token. I also added a shared RPC contract file with a build-time checker, so the client and server can't drift apart on method names or shared constants without the build failing.

Movement, one bug at a time

Movement is client-predicted and server-authoritative. Getting the two to agree took most of the day:

  • Double rotation. The client sent input already rotated by the camera yaw, and the server rotated it again. The server's copy walked along twice the angle.
  • 1.5x speed. The server moved the body from the frame tick, not the physics tick, so it stepped 30 times a second at a 0.05 s step.
  • WASD did nothing. A normalisation check used > 1.0, and a plain cardinal key has length exactly 1.0, so it fell into the "zero" branch.
  • Flat box vs real terrain. The client had terrain and the server had a flat floor. On slopes, horizontal speed diverged. Now both load the same Terrain3D data. On a headless server, collision has to be built for the whole map because there's no camera to build it around.
  • Camera shake. The client copied the server's yaw, which is always a little old. Yaw comes from the client's own input, so the client already has the right value.

I also wrote a divergence probe: a headless client that drives scripted movement and measures how far client and server disagree. That's what turned "it feels twitchy" into numbers I could compare.

The ghost

The real cause of the stutter turned out not to be movement code at all. When a client vanished without disconnecting cleanly, its session never went away. The server kept simulating the ghost and broadcasting it, so every packet carried two entries for my character, and the client reconciled against a dead position every time. The ghost also sank into the terrain, got shoved upward by the physics solver, and was then saved, which is why I kept logging in mid-air. The reaper now removes the session itself instead of waiting for a disconnect signal that never arrives.

Matching the tick rates

Last thing: the server ran physics at 20 Hz and the client at 60. The client was always three steps ahead, so every packet looked like an error to correct. Matching both at 60 Hz still didn't work at first. The broadcast interval was a float that sat one rounding step above 1/60, so it only fired every second tick. Now the broadcast is counted in ticks, so the timing is exact.

Smaller things along the way: one input router for the whole client, the build commit stamped into the client so I always know which build I'm running, and a Linux export instead of shipping project source.