User Tools

Site Tools


networking

This is an old revision of the document!


Networking/Online Multiplayer

Setting up your game for online multiplayer is considered an advanced topic, so it is recommended that you familiarize yourself with 001 Game Creator in general before attempting to implement this.

An online game generally consists of multiple instances of a game running at the same time, where one instance of the game is considered the server whom hosts the game, and the rest of the instances of the game are considered the clients whom connect to the server.


Procedure

The following is an overview of the procedure of how online multiplayer games function in 001 Game Creator:

  1. Two or more instances of the game are run at similar moments in time.
  2. The server, determined by using a “Comparison Branch” event with the “Is Server” use value, hosts the game using the “Host Server” event.
  3. A client thereafter connects to the server using the “Connect to Server” event.
  4. When the server receives a connection, the “Connection Received” system trigger is executed on the server with a parameter variable “ip” containing the IP address of the connecting client and a parameter variable “id” containing a unique number identifying the client (which can be used in other events).
  5. Once the client realizes that it has made the connection, the left branch of the “Connect to Server” event continues to execute.
  6. The server and client may freely communicate using Network Messages. That is, the server can execute a network message event causing all clients or a specific client to run the script inside. And vice versa, the client can execute a network message event causing the server to run the script inside.
  7. The server, at any point in time may close the connection using the “Close Connection” event; this can be based on the “ip” value provided by the “Connection Received” system trigger. The client, at any point in time may close the connection in the same way.

Client and Server Roles

During the development of your game, 001 Game Creator offers an option for you to execute multiple instances of the same game by using the “Launch instances for network games” option within the testing options. When the value is 2 or higher, the first instance will be considered the server and the second instance will be considered the client. That is, “Is Server” use value will return true for the first instance and false for every other instance. However, if you simply execute the same game multiple times on the same computer once the game is built, each instance will be considered a client unless the game is built as a dedicated server.

Regardless of whether the game is launched as a client or server, any instance may either host a game or connect to one. This allows you to setup a game in a peer-to-peer (P2P) fashion using purely clients, simply by allowing the user to choose whether they would prefer to host the game or connect to another.

networking.1468777687.txt.gz · Last modified: 2016/07/17 12:48 by Mike