Home/Engines/Unity multiplayer

engines · Unity

Unity multiplayer

Unity's own multiplayer stack still leaves you choosing, paying for and operating where the server runs. The Multiplayer API is hosted and engine-agnostic: your Unity build, your WebGL build and a browser version all join the same rooms.

Free sandbox · $19.99/mo to go live · cancel anytime

why

Unity multiplayer, hosted

Install the package from the Package Manager by Git URL. Add com.unity.webrtc to connect players directly; without it, everything routes through the server relay and still works — useful on platforms where WebRTC is not available. Unity 2021.3 and newer are supported.

Because the API is not tied to Unity, a single game key serves every build you publish. A mobile player and a browser player can quickmatch into the same room.

code

A complete Unity integration

using MultiplayerApi;
using Newtonsoft.Json.Linq;
using UnityEngine;

public class Net : MonoBehaviour {
    Multiplayer mp;
    Room room;

    async void Start() {
        mp = new Multiplayer("mp_pk_...") { DisplayName = "Alice" };
        await mp.Login();
        room = await mp.Quickmatch(new JObject { ["mode"] = "ffa", ["max_players"] = 8 });

        room.OnMembersChanged += members => Spawner.Sync(members);
        room.OnPeerMessage    += (bytes, from) => Ghosts.Apply(from, bytes);
    }

    void Update() {
        if (room == null) return;
        var p = transform.position;
        room.Send(new { x = p.x, y = p.y, z = p.z });
    }
}
architecture

What goes where

ChannelCallDeliveryUse it for
Directroom.send(data)peer-to-peer, best effort, zero server costpositions, aim, animation
Stateroom.set(path, value)server-validated, kept for the match, reaches late joinershealth, score, whose turn
Eventsroom.emitEvent(topic, data)ordered, guaranteed, not persistedchat, rematch, one-shots
  • Throttle Send to 15–20 times per second in production; interpolate the rest.
  • Password recovery is built in: your server requests a token with the secret key, the client calls await mp.ResetPassword(token, password).
  • Non-browser clients send no Origin header, so the origins allow-list never blocks a Unity build.
Questions
Is this a replacement for Unity Netcode for GameObjects?

It replaces the hosting side: accounts, matchmaking, relay, signaling and validated state are hosted for you. You keep your gameplay code and sync what you choose over three simple channels.

Can Unity and web players play together?

Yes. One game key serves every build, so Unity, WebGL and browser clients join the same rooms.

Does it work without com.unity.webrtc?

Yes. Without it, the SDK routes all traffic through the server relay.

Make your game online today

Free sandbox keys in one call, no account and no card. $19.99/month when you ship, for every game you make.

Free sandbox · $19.99/mo to go live · cancel anytime