Page 1 of 2 12 LastLast
Results 1 to 20 of 29

Thread: Network Multiplayer Template (Server X Thin Client) - WIP

  1. #1

    Network Multiplayer Template (Server X Thin Client) - WIP

    After studying python network libs, I made this template (still work in progress !!).
    This demo is already a fully functional example of a networked multiplayer game (using server X thin client architecture).

    A brief explanation of the architecture is here
    This demo is a 3D Pong, where two players can be at diferent computers in the internet

    How to test in one machine:
    1. Open and run the server first. It will start listening two connections. Blender will freeze because this is a blocking operation. Let it opened. (Multi-threading python is causing Blender crash in my machine)
    2. Open another Blender with the client and run it. This Blender will connect via TCP to the Blender server. Again, this new Blender will freeze because we need to wait the second client/player to start the game (this synchronization is done by blocking TCP reads)
    3. Open a third Blender with the client. When you run it, this third Bender will connect to the server and the game begins !!! Try to put the windows side-by-side to see the fast syncrhonization achieved using UDP messages
    4. Use W, S, A, D keys in the two clients to see how the state is spawned to server and the clients. Ball physics is spawned automatically !

    For now, to test in networked machines you need to change the IP adresses in the scripts. Remember to always start the server first ! The network protocol is the python serialization function in the module "pickle".

    To python prgrammers: Discover how one client can "cheat" the server in this example

    (I think you really need python installed to this work)
    Server blend: http://uploaded.to/?id=we92g8
    Client blend: http://uploaded.to/?id=m0gmfg

    I'll try a tutorial on this when completed.
    UPDATED: Server now tracks score and clients are textured and has shadows. Now I'll try to make multi-threading connection works
    Attached Images Attached Images
    Last edited by morgade; 03-Nov-08 at 12:32. Reason: Links updated by request



  2. #2
    Donating Member braveheart's Avatar
    Join Date
    Apr 2006
    Location
    Scotland
    Posts
    995
    Yes for it to work you need Python 2.5 (as you do for mine). I also noticed that blender freezes if the server is a .exe, you should make the server just a Python module, that way you can just run it as it's own console no need for blender.

    Hmm, maybe you could help me with sycing zombie/door/bullet (from a gun ) movement?

    Thread: http://blenderartists.org/forum/showthread.php?t=100617


    Please upload elsewhere! I hate rapidshare you need to wait an hour between downloads!



  3. #3
    Member
    Join Date
    Nov 2006
    Location
    In the most peaceful country ever....
    Posts
    950
    Originally Posted by braveheart View Post
    Please upload elsewhere! I hate rapidshare you need to wait an hour between downloads!
    Are you sure about that? I just downloaded both? Took 15 secs...



  4. #4
    UPDATED: Server now tracks score and clients are textured. Now I'll try to make multi-threading connection works

    [Oups... Textures where not packed]

    Server blend: http://uploaded.to/?id=i4jwnm
    Client blend: http://uploaded.to/?id=ra9u5f

    Hmm, maybe you could help me with sycing zombie/door/bullet (from a gun ) movement?
    I'll look it.
    Last edited by morgade; 15-Jul-07 at 13:36. Reason: Textures where not packed



  5. #5
    Member blendenzo's Avatar
    Join Date
    Apr 2006
    Location
    Michigan, USA
    Posts
    2,702
    It works great on my PC. I don't have a setup to be able to test it on a network right now, but I'm curious to hear what kind of results it give.

    A couple of things:
    You forgot to pack the textures (looks nice in the screens, though).
    The game currently doesn't recognize when one client quits or the connection is lost, so the remaining player might continue for a little while wondering if the other person is still there.
    "From somewhere, a transmission..."
    Game Engine tutorials: TutorialsForBlender3D - blendenzo.com - blending-online
    My Projects: Escape the Room - Brought2Life - UpRight - Solomon's Treasure - Sokoban - Marble Labyrinth



  6. #6
    You forgot to pack the textures (looks nice in the screens, though).
    I noticed the textures where not packed. Just uploaded a packed version now.

    The game currently doesn't recognize when one client quits or the connection is lost, so the remaining player might continue for a little while wondering if the other person is still there.
    I know. The server must detect when one client disconnects and send a special message to the remaining client signaling the end of the game. These synchronization issues are the ones that demands more coding. Also, I'm having problems starting new python threads (the threads don't start or Blender crashes)
    I will pack this simple version to people study and will try to implement the synchronization code.



  7. #7
    It works fine for me with blender 2.43 and python 2.4. Its really cool, and if you made a tutorial, you would be awsome in my book.



  8. #8
    Banned Member
    Join Date
    May 2007
    Posts
    3,015
    God this might be exactly what we are looking for!

    could this be expanded to like 4 players?

    p00f and I are planning on a chess game, where the pieces settle the the disputes in a 3rd person death-match in various arenas,
    (based ancient commodore 64 game by the first Electronic arts, Archon, and Archon 2)

    Man, I got to see if we can try this at work on the LAN!

    thanks for making this



  9. #9
    Donating Member braveheart's Avatar
    Join Date
    Apr 2006
    Location
    Scotland
    Posts
    995
    Originally Posted by morgade View Post
    I'll look it.
    What do you mean?



  10. #10
    Member ChicOrtiz's Avatar
    Join Date
    Sep 2003
    Location
    Brazsil
    Posts
    829
    Hey, very cool.

    Sadly i was not able to play. I click inside the blender clients and "wasd" doesn't work... But Blender tell that "conections" are ok (server was able to "catch" clients). :S

    Using python 2.5 and Blender 2.44

    Later i will try Blender 2.43 and python 2.4 like Ragshan did.

    Congratulations for the excelent work!



  11. #11
    could this be expanded to like 4 players?
    Yes. It's all about plain python programming. The server can handle a list of clients (with sockets and addresses), and send messages to all clients in the list.
    One important first step is define the comunication protocol between client and server (put it on paper to not get lost). I'll put this in the tutorial
    I tried it in a LAN (actually two PCs connected by a cross-cable), and worked fine

    What do you mean?
    I mean I will try help with your problem later (Sorry ... Read my signature)



  12. #12
    Donating Member braveheart's Avatar
    Join Date
    Apr 2006
    Location
    Scotland
    Posts
    995
    Originally Posted by morgade View Post
    I mean I will try help with your problem later (Sorry ... Read my signature)
    Great! I really hope you can help.

    Blender also froze for me and never worked, i'm using blender 2.44 & Python 2.5.



  13. #13
    I followd your directions but i still cant get it to work, all that happens is the server runs but then its says invalid syntax socket?



  14. #14
    Originally Posted by rowboat View Post
    I followd your directions but i still cant get it to work, all that happens is the server runs but then its says invalid syntax socket?
    Can you post the complete error message ?



  15. #15
    Member PlantPerson's Avatar
    Join Date
    May 2002
    Location
    Milky Way Galaxy
    Posts
    5,777
    OMG this is just waht i need make raelly cool mmorpg... i am making team will people pls sign up help make my game? Thanks!!!111!!!!111 lolz

    Just kidding...
    This is really great morgade (although I don't think I can test it), thanks a lot for this excellent contribution to the BGE community. This makes a great addition to Social's FPS and Walkthrough templates. Maybe in the future we'll have more templates and therefore fewer stupid questions? All we need now is the "raelly cool game" template...
    "If we shadows have offended, Think but this, and all is mended, That you have but slumber'd here. While these visions did appear." - William Shakespeare
    Portfolio | Blog | Webcomic



  16. #16
    Member chuzzy06's Avatar
    Join Date
    Feb 2006
    Location
    Massachusetts
    Posts
    356
    Originally Posted by PlantPerson View Post
    OMG this is just waht i need make raelly cool mmorpg... i am making team will people pls sign up help make my game? Thanks!!!111!!!!111 lolz
    OH NO..PlantPerson = noob
    Originally Posted by PlantPerson View Post
    Just kidding...
    PHEw

    This multiplayer template is a great idea! as far as i know this is the first time it was made( I know it was thought of more than once). Also, nice choice of pong for a template, its simple and anyone who wants to learn networking in blender can easily do so with this.



  17. #17
    Member Olm-Z's Avatar
    Join Date
    Apr 2006
    Location
    Bxl - Be
    Posts
    325
    hmmmm ... I think that you mised the BZoo (alias BlenderZoo) template, which is working pretty well allready !

    the only thing is that I never been able to have the server noticing the disconnection of players when running on Linux, so I left it where I was with it last year ....

    But I think it could be corrected by some python guru out-there ...



  18. #18
    This worked Perfectly on my computer. Great work. This is REALLY GOOD. Super fast framerate too.
    It seems to work on blender 2.42a and blender 2.43. (with python 2.4).



  19. #19
    Member alienkid10's Avatar
    Join Date
    Jan 2008
    Location
    blender
    Posts
    1,111
    When I try to run it from my computor ro my bros with the server runing on mine it gives him a massage in the console saying "no attebte 'myid'" what do I do?



  20. #20
    Cool! I always wanted to figure that out.



Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •