WIP - Fast and optimized BGE Networking

I’ve noticed a lot of people use pickle as a data format in networking in the BGE. This is very un-optimized and uses more bytes than it should to send data. In my BGMC 31 game, RAT4T4, I implemented a multiplayer system that sends data to a server in the form of a struct. Using this, I was able to compact the data of 9 players within 128 buffer size of the socket. Using pickle, the buffer size would have to be over 256 bytes for the same data for just 1 player. Clearly the benefit is obvious.

I will be attempting to create a user-friendly and modular networking system for the BGE based on the struct method that will be able to connect to my server which will be able to adapt to any type of data it receives from the clients.

Updates will be posted here soon.

6 Likes

Are they ? :smiley: In addition it’s not safe AT ALL ^^
Malicious code can be sent in a pickle packet, and if not handled corretly, control of all the machine / server can be taken soooooo easily :joy:

I use to do so, or I also json dumps eventually for mostly string containing packets

yes. security is a big issue I have yet to figure out

1 Like

Awesome buddy cant wait to see more updates!
:sunglasses::+1:

Fred/K.S

Any updates for this in UPBGE?

not yet. feeling pretty bored rn so might work on it

1 Like

Epic bro!!!

And it will be user friendly right??

It has been a while since i said I would make an easy multiplayer system for Blender games and now I am halfway there.

Here is a link to a script that allows a dictionary object that can contain player and client information, for example, to be encoded and decoded to and from bytes in order to be sent over the air. The format is very compact, modular, and efficient for use in networking. But please, if you can think of ways to improve the format, let me know.

Here is that link: https://pastebin.com/xkiYrrQz
one more thing, that script uses the struct lib. Refer to https://docs.python.org/3.5/library/struct.html#format-characters to properly format your data (line 4 of the script)

My next step will be to integrate this both client and server-sided and then to get them to communicate :slight_smile:

And one final thing. My computer will be available for hosting games either for free or for a small price if integrated. I have 100mbps internet

4 Likes

Amazing would be honored to give it a shot bud thanks for referring me
If we successfully manage to bring TBW - Multiplayer to the table this could be EPIC with the kind of maps im making these days for my mission Levels!

!!! THE VIDEO BELOW JUST SHOWCASES THE UI Design so far !!!


Fred/K.S

3 Likes

I did an earlier test multiplayer with the guys on discord the 1st template was a great experiment and we were able to have an successful 6 player death match mode Live in UPBGE!
(Connection was stable but new joining in players would frequently stutter the game but it turns out that our multiplayer template was a more aggressive approach)

2 guys were using UPBGE 0.2.0 i was one of them and the other 3 were using 0.2.4 which was great and compatability worked nicely.

However the integration in to the TBW - Multiplayer template also worked and proved successful but we had a bug that showed players as cubes, in retrospect it was mainly showing player collision bounds lol.

here are some shots from our playthroughs: (WE ARE NO LONGER USING THIS CUZ THE CODE ISN’T REFINED !!!)

@Wkk had a peak through the code and thought he could refine it but it turns out no one understood or could implement such a fix! Screenshot (3435)

But i believe your code is the most refined, and i’ll be looking forward to working with you in the future regarding Multiplayer for TBW - #An UPBGE Game!

Best Regards

Fred/K.S

1 Like

The actual code that takes care of sending and receiving data is not important. The most important part of the system will be the way the data is handled. I spent hours working on the design for the encoding and decoding that will be easy to use by anybody and is very compact so as not to use too much bandwidth.

My next plans are to make it so that the client and server only send data when the data has changed, rather than send it continuously to save bandwidth. Additionally, I will be incorporating interpolation which will smooth out the movement of players and objects.

2 Likes

Noice! I see :thinking: :slightly_smiling_face:, it looks like it’ll be a very neat approach to this system; ayt bud im looking forward to this buddy :sunglasses: :+1:

Fred/K.S

Nicholas_A, dude this looks awesome. I am not good at coding, but from what your saying this is next level multiplayer stuff. Hope you get it refined and out there :slight_smile: thanks for all you have done :slight_smile:

Using the packet.py module linked in the first post, you can test the networking system with this client script: https://pastebin.com/mfquUnwq

The script sends random data to the server (running on my pc) and it will ping the same data back to you and all other clients that are connected.

2 Likes

Working setup

4 Likes

Wow, this is really cool! I remember playing the FPS demo with @Fred_K.S and others on the Discord and it was actually quite good, I look forward to more innovation with multiplayer

1 Like

Im currently part of a GROUP Testing a NEW Networking Tool Addon specifically being Developed for UPBGE 0.3.0 Aand currently it holds up to 64 players

The guys are currently testing it until the netcode is officially refined i will make a demonstration with one of my games and how its going to work this one will allow us to run the server directly on UPBGE 0.3.0 on a separate pc and have all players connect to the server hosting the mode or the lobby and also allowing players to have private sessions within the same network segment.

its currently in Alpha development, but as i say my focus isn’t really multiplayer as 1st priority my main priority is to get all base games out and have people playing then expand on networking capabilities… Bridging the gap between how do i take the fun i have alone in my single player experience and share it with my friends around the world.

I think once the multiplayer reaches BETA level i could fully feature a mode in one of my UPBGE Games and have a lobby of 64v 64 players and hopefully the UPBGE Community can join in and have fun together as we test the networking in the game for future UPBGE Games !!!

Fred//K.S

Ok, well my method can host an unlimited number of players

2 Likes

Like i said i will be testing out various versions so pls be open and feel free to share with me as well u never know which one works best, so far the current one i played with a while back well my 1st UPBGE networking experience was a BLAST lol and that method is quite Aggressive because of the way it was set up.

Youre procedural method is another way of achieving successfull multiplayer and the new one which is an UPBGE EEVEE Addon has high promises.

@Nicholas_A id say get yours to be the best version yet so that a variety of projects can test it out on UPBGE legacy… so basically the versions of UPBGE before Blender 2.8+ and UPBGE 0.3.0

Get your Addon as a masterpiece for Legacy UPBGE so that people can test it out and give you some good feedback !

Because right now netcode is complex and the UPBGE 0.3.0 version seems to be on a different level and only works for the b2.08+

Fred/K.S