Blender Game networking test

Now that I am working on a game, using Python cPickle and Socket, i was able to create a peer to peer, symmetrical network implementation for the multiplayer aspect of the project.   Using some 30 lines of Python, each player would ‘trade’ data with its peers.

YouTube  Demo:

I am using UDP, so it’s naturally faster than TCP/IP, but delivery is not guranteed.  But for realtime games latency is the main concern, so UDP is definitely the way to go.  The video shows me controlling a cube on the desktop computer (monitor to the right), it’s position data is sent across the internet* to the laptop which displays a similar cube.

Close to the end of the video, I turned off the Wi-Fi on the laptop, killing the network connection.  As expected, the cube stops updating, when I turn it back on, it takes a few second to reconnect, and then the cube starts moving again.

*I route the network traffic through another computer somewhere in town to simulate a more realistic network delay.

  1. Nice implementation. I would like to see the files later, to try to make a more server-client solution. (smart server – dumb clients)

    A thought on multiple displays with network (or how I’m planning to use it :) ):

    We could have a camera in the server with an empty parented to the camera (+ copy locrot constraint). This would be the server

    In the client we take the original camera and move/rotate according to the display, parent the camera to the empty and sync the empty with the server. That would be a dumb camera.

    I think that could be used to for panoramic/cylindrical surfaces or multiple projector domes.

    It made me think (:

    Best regards,
    Dalai

    • mikepan
    • July 23rd, 2009

    I have the source code here: http://blenderartists.org/forum/showthread.php?t=161961

    A server-client approach is even easier, i think. And moving data seems easy enough, cPickle can serialize any object into strings, but is a bit too bloated since it packs in a lot of ‘useless’ structural stuff. For what I am planning to do, I will manually concatenate everything into a single string and parse it on the other side, error prone, maybe. But a lot less data.

  2. Your P2P approach sounds very interesting. I’d love to mess with your game’s scripts when it’s released. :P
    Change the way it parses the data.
    Then play with a friend and beat the crap out of him.

    • mikepan
    • August 6th, 2009

    yeah well, ‘hacking’ is certainly possible given how primitive my approach is. Although I could just release the compiled python file and never show anyone the source code. Disassembling a pyc file might still be possible(is it?), but at least it’s security through obscurity. I learned that last bit from Microsoft :D

  1. No trackbacks yet.