Multiplayer


ServerBytes multiplayer plugin helps you make your game more social by adding multiplayer features.

This plugin allows you to create multiple rooms per player, search and join the rooms.

Rooms can have custom properties which are great for matchmaking.

Once inside the room, players can broadcast messages to everyone, and they can create actors. Each actor represents a single entity, has state, and can broadcast a message.

This plugin requires Authentication plugin to be installed.


Installation

To add Multiplayer to your game, simply download Unity package and import it into the Unity game, or download Nuget package.


Client

Client setup The very first step to initialize the plugin is to setup the plugin host:

var pluginHost = ClientFactory.GetPluginHost(appKey);
var multiplayerFactory = new MultiplayerFactory(pluginHost);

// instantiate other plugins,
// create the client
var Client = ClientFactory.GetClient(pluginHost);

Client.OnConnected += Client_OnConnected;
Client.OnFailedToConnect += Client_OnFailedToConnect;
Client.OnDisconnected += Client_OnDisconnected;
Client.Connect();

Read more about installation here

Once the plugin is registered, and the client is connected, we can start using multiplayer.

private void Client_OnConnected()
{
    IMultiplayerService mpService = multiplayerFactory.Create(Client);
}

To start using multiplayer plugin, read more about rooms here.

Glossary

Type Description
Room Base class for rooms.
RoomInfo Contains metadata for a room.
Player Contains metadata about a player.
Actor Contains metadata about an actor.
ListRoomsQuery A query for searching rooms.
IMultiplayerService Provides methods for listing rooms.
IBinarySerializer Serializer for multiplayer messages.
IBinaryWriter Writes primitives to buffer.
IBinaryReader Reads primitives from buffer.

results matching ""

    No results matching ""