Menu
Lumberyard
User Guide (Version 1.13)

Multiplayer Sample

The Multiplayer sample shows you how to build and structure multiplayer games that use the various features of the GridMate networking library. The new preview attempts to incorporate as many GridMate features as possible but is not comprehensive. Instead it is intended as a living snapshot of the current state of the networking library. Consequently, as the sample evolves, features might be added to enhance functionality or removed to keep the sample concise.

Building and Running the Sample

Follow these steps to build and run the sample.

To build and run the Multiplayer sample

  1. In the Project Configurator set MultiplayerSample as the active project.

  2. Run the following command:

    lmbr_waf configure
  3. Run one of the following commands, which builds everything in the profile.

    • If you are using Visual Studio 2015, run this command:

      lmbr_waf.bat build_win_x64_vs2015_profile –p all
    • If you are using Visual Studio 2013, run this command:

      lmbr_waf.bat build_win_x64_vs2013_profile –p all
  4. Run the MultiplayerSampleLauncher.exe file from your default bin directory.

    • For Visual Studio 13, use Bin64vc120.Dedicated.

    • For Visual Studio 15, use Bin64vc140.Dedicated.

MultiplayerLobby

This level demonstrates a multiplayer lobby that uses GridMate networking. Currently, the level performs the following tasks:

  • Creates a server

  • Displays a list of servers on the local LAN

  • Connects to a server

To create a server

  1. Type the server name in the Create a Server form.

  2. Click Create Server.

    The game starts hosting and loads the selected map.

To connect to a server

  1. Find your server in the server browser list. If your server doesn't appear, click Refresh.

  2. To select your server, click the row that contains your server name.

  3. Click Connect.

Game Overview

The Multiplayer sample is an arcade space shooter. Each player controls a ship in a giant field of asteroids. Each player must fly through the asteroids and destroy as many of them as possible in an effort to achieve the highest score. Additional points are awarded when other players are killed. Points are deducted every time the player dies. In addition to the threats posed by asteroids and other players, gravity wells scattered around the map can draw players in and trap them. Players who become trapped in a gravity well die instantly.

When a ship is spawned, three kinds of ships are assigned randomly:

  • Fighter – An average space ship.

  • Speeder – A faster and more maneuverable space ship but less sturdy as a result.

  • Rammer – A sturdier ship that is weaponless but designed to smash into asteroids and destroy them. The ship is fast but has poor maneuverability.

When destroyed, some asteroids spawn collectibles that award a short-time power-up bonus. These power-ups include extra damage against certain targets, a longer power-up time, and extra protection against certain sources of damage.

Game Controls

The following tables list command controls for keyboards and Xbox controllers.

Keyboard

Key Action
WASD keys Move the ship relative to the screen (W is always up, S is always down, and so forth).
Arrow left, arrow right Rotate the ship clockwise or counterclockwise.
Spacebar Fire the ship's weapon (if applicable).
Tab (hold) Open the Player Stats window.

Xbox Controller

Control Action
Left joystick Move the ship in absolute terms relative to the screen.
Right joystick Rotate the ship clockwise or counterclockwise.
Right shoulder button Fire the ship's weapon (if applicable).
Back button (hold) Open the Player Stats window.

PS4 Controller

Control Action
Left joystick Move the ship in absolute terms relative to the screen.
Right joystick Rotate the ship clockwise or counterclockwise.
R2 Fire the ship's weapon (if applicable).
Options button (hold) Open the Player Stats window.

Touch Controls

Control Action
Virtual joystick (left side of screen, no visual indication) Move the ship in absolute terms relative to the screen.
Virtual joystick (right side of screen, no visual indication) Rotate the ship clockwise or counterclockwise.

Notes

  • As soon as you begin moving with either virtual joystick, the ship begins firing (if applicable).

  • These controls can also be accessed by using the mouse (click to touch).

  • If you fire manually, the automatic firing stops until the next input from one of the virtual joysticks.

Game CVars

The following console variables can be used with the game.

mps_AISteeringDebug

Specifies whether the debug drawing information for the bot is drawn.

mps_ControllerType <number>

Controls the type of PlayerController that the client uses to control the assigned ship. The following table shows the possible values for <number>:

Value Description
0 Specifies manual control. A user controls a single ship.
1 A bot that plays the game.
mps_DrawBucketSystem

Specifies whether the debug information for the bucket system is drawn.

mps_SpawnTag

Controls what ship is spawned for a player when the player spawns a ship. Possible values are shown in the following table.

Value Description
Random Chooses an available ship at random. This is the default value.
Fighter Spawns a fighter ship.
Speeder Spawns a speeder ship.
Rammer Spawns a rammer ship.
mps_UserName

Specifies the name for the client in game elements such as the scoreboard or action notification.

Creating a Dedicated Server

To create a dedicated server for the game, perform the following steps.

To create a dedicated server

  1. In the Project Configurator set MultiplayerSample as the active project.

  2. Run the following command:

    lmbr_waf configure
  3. Run one of the following commands, which builds everything in the profile.

    If you are using Visual Studio 2015, run this command:

    lmbr_waf build_win_x64_vs2015_profile –p all

    If you are using Visual Studio 2013, run this command:

    lmbr_waf build_win_x64_vs2013_profile –p all
  4. Run one of the following commands, which builds game_and_engine in profile_dedicated.

    For Visual Studio 2015, run the following command:

    lmbr_waf build_win_x64_vs2015_profile_dedicated –p game_and_engine

    For Visual Studio 2013, run the following command:

    lmbr_waf build_win_x64_vs2013_profile_dedicated –p game_and_engine
  5. Run the MultiplayerSampleLauncher_Server.exe file from your default bin directory.

    • For Visual Studio 13, use Bin64vc120.Dedicated.

    • For Visual Studio 15, use Bin64vc140.Dedicated.

Supported Platforms

The Multiplayer sample is currently supported on a variety of client and server platforms.

Clients

The following playable client platforms are supported:

  • Windows (Visual Studio 2013, 2015)

  • Android

  • iOS

Dedicated Server Platforms

The following dedicated server platforms are supported:

  • Windows (Visual Studio 2013, 2015)

  • Linux (Ubuntu)

About Self-Signed Certificates in the Multiplayer Sample

In Windows, the Multiplayer sample enables client-side self authentication that uses a self-signed certificate, which the build script generates for each user. Regarding this certificate, keep in mind the following points:

  • The self-signed certificate is not an official certificate. If you want to ship a publically available game, you must replace it with a public key certificate.

  • On the macOS and Linux platforms, you must generate self-signed certificates manually.

  • On the macOS and Linux platforms, the Multiplayer sample has the following limitations:

    • macOS: Only iOS client builds can be made.

    • Linux: Only dedicated server builds can be made.

Troubleshooting

The following are some connection troubleshooting tips.

  • If clients are unable to discover a server, ensure that the server and client are on the same subnet in order to allow for UDP discovery.

  • If clients are unable to connect to a server, ensure that the server and client are using the same key and certificate files.

  • When trying to host or join a session, you might receive one of the following error messages:

    Invalid Secure Socket configuration given for hosting a session. Ensure that a Public and Private key are being supplied.
    Invalid Secure Socket configuration given for joining an encrypted session. Ensure that a Certificate Authority is being supplied.

    To resolve these issues, perform one of the following tasks:

    • Run the command lmbr_waf configure to generate a set of certificates.

    • In the MultiplayerSample/certificates directory, provide your own appropriately named certificates.

    For more information about self-signed certificates, see Encryption in the Multiplayer Sample Network Features section and About Self-Signed Certificates in the Multiplayer Sample.