Woohoo! Syncronized clients finally!

For the past 2 weeks I’ve been trying to build my own version of the Distributed Node code that comes with Panda. Don’t get me wrong, the code they’ve given is really awesome, but I couldn’t figure out the details of how it all worked, which greatly limited my ability to modify it without reading every line of code in the example project that was posted as well as every line of code in the distributed include folder (I tried, and couldn’t get very far).

So I set out to try and do it myself and finally did it. Each client can connect to the server, select their character, and then enter one of the zones. Upon loading a zone, the server will send them updates to every avatar in the zone every second (I haven’t figured out how often I need to send the update, so for now it’s every second).

Right now, when you login and select your character, the server will automatically adjust the hpr of your model every second (I haven’t coded in any kind of movement functions yet). So here’s what 2 clients connected would see (each image is about 5 seconds apart):

I’m still cleaning up the code and building more, but I’m hoping to release this at some point in the near future if anybody wants it. So far it’s pretty bandwidth-light, I’ve been closely monitoring the packet sizes and the update packet seems to be about [250 bytes x # of connected clients]. In the above picture with 2 clients the update packet that was sent out every second consume 481 bytes (which includes the XYZ position, hpr, unique ID, and a few other configuration elements for each avatar in the zone). I’m figuring that by the time it’s got all the data in it that I want, it will take about 300-350 bytes/client.

The code isn’t anywhere near as robust as the distributed node code, but it’s pretty simple and it works. The client code is 425 lines (probably 150 of which is comments), the server code is 620 lines (probably 200+ lines of comments in it). There’s also a separate include file that is called by both (but it’s only 40 lines long).

Next step - deleting avatars! Right now, if a client disconnects it doesn’t remove the avatar from the playfield, it just stops updating it every second lol. So with the 2 pandas in my example above, it 1 client disconnected, the remaining active player would still see both pandas but only his panda would continue rotating.

I’d like to give a huge thanks to David (drwr). He’s been amazing at providing support for my stupid questions that I’ve been flooding the scripting forum with :slight_smile:

You have an interested post.
You’re such a genius,your client might appreciate your effort.
keep up the good work.