All about Multiplayer

I’m trying to incorporate multiplayer into my soon-to-be game. If I do everything a youtube tutorial says, it will work, but I didn’t learn WHY and HOW it works, in general I didn’t learn anything about multiplayer. I just have a couple questions, and I might add more if I need to, but does anything know the answer to these questions? I don’t know why multiplayer is such a non-controversial topic that very few know anything about…

I’m using Angus Holland’s “Multiplayer Add-on 1.6.8”, so these questions will be based on that.

Why do you need a player representation (entity, I think it’s called) to appear on the server?
What does the server do, because I just click “Host server” and it works, but can I do with the server host .blend file?
How do I spawn in something via edit object and make it automatically disappear?
Will ray sensor with in the “Game world” of multiplayer?
How come so little know about multiplayer when multiplayer has been around for a while and is very popular?
If I spawn in a character into the game world, will everything that’s parented to it spawn in with it, and be visible to the other clients?
Will the multiplayer addon by hollands be work for more advanced games?
Are there any other tutorials/add-ons that are more advanced (give more flexibility/ more efficiency) out there?

Sorry if these are a lot of questions, but if you have an answer to any of them, please post. Thanks.

I have a video tutorial that explains some of this in detail:

The addon was designed as a simple peer to peer esque relay (server client, but the data originates from the client, rather than the server. I don’t recall that the server needs to recreate the client, but it does as a side effect

In terms of a better solution then I’ve written a multiplayer library that deals with advanced applications. You cannot expect to use logic bricks to do multiplayer to a greater level as you cannot express yourself with enough fidelity

@agoose777: I was just saying if the add-on can be used for much more complex multiplayer games, and IF it can’t what other options do I have?
@Goran: Thanks for the video, although some things were very confusing and not explained in-depth, still I learned quite a bit from it :slight_smile:

Also one more question: If I use the start menu to make the character spawn, will it also spawn in the objects that are parented to it? So if it spawns the character plus otherstuff, will that other stuff show up on the other clients if I only have the character with Play Game?

Which things?

If you can be specific, I can probably clear it up for you.

To do anything with multiplayer, you have to understand a little about how computers and networks actually work.

I try to visualize things as a postal system.
We have a bunch of things:

  1. A letter
  2. A street name
  3. A post box

In network form these are:

  1. A packet
  2. An IP address
  3. A port

So let’s say that computer A wants to talk to computer B. It says to the postal service: I’ve got a mailbox over here at this street. I’d like you to run a service to deliver messages to this other mailbox at that street over there.
When you do this in python, you create what is called a socket.

Normally, sockets are ‘blocking’ which means that computer B won’t do anything until it’s received information from computer A. Unfortunately this would freeze the game, so we have to make sure it doesn’t do this by setting it to non blocking. I can’t think of how this is in the postal service unless the person recieving the message is so caught up waiting for the next one they can’t do anything until it arrives.

So how we have our postal route, we can send stuff along it. We can send any string of bytes that we like, generally things like position and rotation. One can convert strings into bytes and anything really using various python modules.

Then when the game finishes, we have to make sure we tell the post office we don’t want the route any more, because otherwise we keep paying for it! If it stays open, you can’t use it again until it’s closed: you can’t connect to another computer with that same port.

And that is a very rough description, but I hope it gives you some clues about the jargon, and how networking is done.

Multiplayer explained very easy:

It is a game that deals with the input of multiple users and presents output to these users at (nearly) the same time.

You do not need any complex techniques. The users can share the same resources e.g . the same keyboard, the same screen. If you need different views for the players -> split screen.

But if you want separate terminals you have to go for:

Network Multiplayer:

It is a game that deals with the input of multiple users and presents output to these users at (nearly) the same time +
communicating over a network.

These network part makes it difficult. Basically you get one game for each communication point (instance). The networking framework is going to synchronize the different game instances that they feel like one game to the user. There are several strategies, each with its own benefits and drawbacks.

In difference to single instance games, multi-instance games have to care about latency and ambiguous situations. E.g.
A player occupies a position in his instance. Another player occupies to the same position in his instance. Who is right? Such things constantly happens as there is a (hopefully short) delay between the single games.

A good framework provides you with solutions to the communications and synchronization problems. This way you can focus on the game logic rather then the communication. Nevertheless the framework has heavy influence on your game design.

How come so little know about multiplayer when multiplayer has been around for a while and is very popular?

Because multiplayer is very hard. It requires you to really understand both networking and internal game mechanics and that is far from the point of BGE that tries to be WYSIWYG and easy-to-use visual programming. There is complex python, abstraction, representation, interpolation. The solutions are nearly always optimized on per game basis and there is no set way to make things work the best.

Angus’s addon in fact does most of the painstaking steps of building a networking game for you. But you still can’t make much use of it if you don’t know how you should build a multiplayer game.