Multiplayer - Guide

[SOCL-Multiplayer-02]

Multiplayer game development offers additional challenges beyond those of a typical single player game.

When designing a game with Beamable’s Multiplayer Feature, it is important to plan which user interactions will be sent to the servers.

Planning

StepDetail
1. Define the game's high level goals• What are player motivations?
• How is the 'story' of the player told through audio, graphics, animations, etc ... ?

Note: If you are new to Multiplayer game design, this is a good place to start. Think about the game as if it was indeed a single-player experience. Then iterate on the design in the following steps
2. Consider game input from the users• What is each user input gesture?
• What are all possible choices the player may make at that moment?
3. Consider game input from other sources• What else impacts the user experience?
• Are any elements 'random'? How will that be determined, sent, received, and processed by each client?
• Where will delays be required? The game need to wait at key moments for animations to finish, sounds to finish, etc ...
4. Design the structure of the Multiplayer event objects• How many event objects are needed?
• What info is needed in each object?

Note: A solid, purposeful design in this step is important to create a pleasing multiplayer game experience. See The Balancing Act below for more info

These user interactions are relayed as event objects to all connected clients. Each client will deterministically simulate those events to ensure a consistent user experience for all players.

Designing an event-driven, deterministic simulation is vital.

The Balancing Act

Deciding which user interactions require events and how to design the event payloads, striking a balance is recommended.

  • Too Few Events: Each game requires a certain amount of events to faithfully and deterministically keep all players in sync. Sending too few will cause the game to fall out of sync or lack the polish expected by the game community. The same is true if each event contain too little data to represent the needs of the game design.
  • Too Many Events: Each event requires reasonable overhead for serializing, sending, receiving, and processing data. Sending too many can cause latency and the players will notice lag in the user experience. The same is true if the events contain unnecessarily heavy data within each event.

📘

Expert Advice

Here is more info from Beamable's development team:

"Determinism of the game simulation is important due to the nature of our server implementation. Because Beamable's relay servers are game state agnostic, any sort of state checkpointing or CPU architectural differences are not corrected on the server side so in order to keep the game state in sync on all clients, it is imperative that the game be made deterministic. "

• See Ruoyu Sun's Game Networking Article for more info

Steps

Follow these steps to get started:

Note: Step 3 and step 4 are the bulk of the development effort. The details depend on the specifics of the game project.

StepDetail
1. Setup Beamable• See Installing Beamable
2. Setup Content• The content type related to Matchmaking is the SimGameType. It defines the parameters for the match to be created.

Note: See Matchmaking - Guide » Setup Content for more info
3. Create C# multiplayer-specific logic• Access Local Player Information
• Create Multiplayer Session
• Handle Events
• Send Events

Note: See Multiplayer - Code for more info
4. Create C# game-specific logic• Convert input to events
• Gracefully handle network latency
• Convert events into graphics and audio rendering
• Handle game logic (e.g. win/loss conditions)