This week I’ve been diving head-first into Unity’s networking system. I’ll admit it’s a bit daunting to try to develop a good netcode solution for something like Pong 4 Pals (or whatever I’ll end up calling that game), but I’m going to give myself a few days of tinkering to see if I can whip up something decent.
Here’s what I have so far, which is no good. Movement is client-side, so it feels very smooth when you’re moving your paddle back and forth. In contrast, colliding with balls is authoritatively server-side, meaning that you may have moved a few inches to the right, and think you hit a ball coming your way. But the server doesn’t know that you moved those few inches, and so it thinks you missed the ball completely. Thus, initially, on your screen, the ball banks off your paddle safely, but only for a fraction of a second. Immediately afterward, it corrects its position/velocity by curving around and circling back into your goal, once the server updates it and says “nope, this ball went straight in.”
In the following footage, the bottom paddle is controlled by the client:
I’m still pondering what kind of model works best, without any complicated buffers of multiple input frames or fancy interpolation. I’m tempted to increase the network update rate a bit, and then experiment with syncing each transform (instead of each Rigidbody), either through something like a SyncVar, or what I’m doing now (the “Network Transform” component).