Dynamic Networking in blender

Welcome to agoose77’s dynamic networking demo
Dynamic Networking Final (Slow)1.blend (1.17 MB)
(in the latest version, it alerts you if it’s out of date)
In this demo, a very barebones setup allows you to establish a server,
and connect unlimited* numbers of clients without typing any extra code^
Normally, in a multiplayer setup (the basic ones) you must set the default number of players, manually set each player’s port AND they must all be connected to let the game play.
Dynamic networking is dynamic! meaning that there is no specified number of clients, no specified ports and no specified code!
What this does is tell the client how to connect to the server, automatically set it up (the connection) and requires no user input.
This is by no means new - every major multiplayer game has dynamic networking of some means, but the problem here at blenderartists.org is that there are very few (that i know of) that know how networking works, and fewer still who have created a beginners tutorial.
Networking is Not difficult, it just requires some thought.
I will write the documentation soon.
OldJim created this concept in WSAG3x, but it is very hard to understand, as it is customized.

For me, it appears to lag with 2 clients connected, and i’m not quite
sure why at the moment; i think it may be related to multithreading or network usage.

At the moment, this demo is designed to work over lan, on your current network

Instructions

1)open three instances of blender
2)start 1 server, 2 clients. (for the clients, specify the name for each one by typing them)
3)WATCH!

I will see if i can make my public ip forward to my pc.
In the mean time, use this and post on this thread
if you wish to use it the way it’s intended
(that way, it ought to lag less)

[1.1]

[If anyone wishes to help me create a plugin to make this more automatic, PM me]
credits to OldJim - http://oldjim.ch

*Until your network/computer overloads.
^obviously, some code is required XD

Sounds interesting,tho what exactly this script does?what does it allow you to do?

Thanks Agoose77… this gives me something else to tinker with.

No worries.
I must add a few things.
Firstly, this will be updated regularly - at the moment, if you try and run to instances of clients on the same pc, they may fail.
The main problem is that you cannot run a client on the same pc as the server, because it lags.
In order to prevent complaints about old versions, i shall update the link in the post regularly, and it now includes an update notifier, so run the game, and see if you need to update.

EDIT,
Can anyone help me implement this into a plugin in blender?

Do you mean implement it into an add-on? Or do you mean into a single function?

sorry, i meant to ask if someone could help me implement this as an add-on, similar to Unity 3D

I’m working on the same thing (for a system of mine).If i succeed i can see what we can do here (or even better if you are interested in a collaboration we can wrote a script that automatically set up all the needed logic/physics/etc to make systems working, something that can export a file that contains all the needed informations and that can read this file and set up everything inside blender)

1)Exactly, I was hoping to create an add-on which:
Gives the user an easy way to send object properties
Give the user modules to use in game (e.g [pseudo code] bge.logic.createHost(name,port,ip))
Creates all the code into a text file, automatically creating logic bricks on the fly.
2)possibly create a ‘hierarchy view’ which allows a simple overview of what the network is doing.

Gimme 2-3 days and i will send you (pm) the script i’m writing (i don’t share it with the comunity since the system has bugs, but will be the way i’ll use to distribute once finished)
I have a few ideas about how to implement 1).
About 2), i was thinking too to a system that automatically creates hierarchy view, but i have no clue about how to do it (do you know ogame? Inside the game there is a page that, i think, create this type of hierarchy view automatically

What script are you referring to?
I already have a working a networking concept.

http://www.pasteall.org/20993/python

This is an add one that sets up all the logic, object, modules for my script. This means that whoever install the add on, run it, and the system will be working, eg: the new way to share scripts instead of giving blends where everyone must become crazy to understand how to replicate the system.
This works for my script, try it on a new file if you want to see what it does (open a new project, SAVE IT IN A EMPTY FOLDER, rename the cube to whatever different to standard names (Plane, Cube, etc…), run my script, see the logic)
It wont actually work since it needs also other files, but this sets up all the needed logic!
Were you referring to this kind of system?
(ps: my script is for dynamically loading the terrain)

If so, i think that would be a great step further for blender game development to create an add-on that do this automatically (to create the script i needed to write all the commands to set up the logic, and copy-paste all my scripts inside this one as strings (so adding
\ at the end of each line[god bless the macros])), so that all the scripts will be completely user-friendly

Right, so i’ll mock up a few ideas for menus, and you could implement them?

Wow, i am glad to say that i have finished the component integration of my networking.
First version complete!
Check here for my script: Network (Moguri’s Component) (scroll down to find it)
and downloadthis patched version of Blender, then read instructions on my site (link above)