Quickstart

The goal of this section is to be short, easy to follow, and closer to a tutorial than reference documentation. If you follow the instructions on this page, you will have an example server and client running in Unity and talking to each other. You will also see how to add your first networked object and call your first RPC.

Download Projects

Download the latest version of the Client and Server Unity projects. Each project already includes the networking scripts (UCNetwork, ClientNetwork, ServerNetwork, and NetworkSync).

Running the Server

  1. Open the Server project in Unity.

  2. Load the scene named Server.

  3. Hit Play.

The server starts automatically on port 603 (the area code for New Hampshire). By default, all connection requests are automatically approved.

Running the Client

  1. Open the Client project in Unity.

  2. Load the scene named Client.

  3. Hit Play.

Connecting to the Server

The client UI allows you to enter an IP address and port.

  • If you are running the server locally, use:

    • IP Address: 127.0.0.1

    • Port: 603

Once connected:

  • The server approves the connection.

  • The client is placed into Area 1 by default (see areas).

  • The client spawns a networked Player object and adds it to Area 1.

To test multiple players, build the Client project and run the executable outside of the Unity editor while leaving the editor client running.

Your First Networked Object

Let’s make a new networked prefab that spawns across all clients.

  1. In the Client project, create a prefab called Cube.

  2. Place it in a Resources/ folder.

  3. Add a NetworkSync component to the prefab.

  4. In any client script, call:

    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            clientNetwork.Instantiate("Cube",
                new Vector3(0, 1, 0),
                Quaternion.identity);
        }
    }
    

Now, whenever you press Space, a cube appears on all connected clients, synchronized through the server.

Your First RPC

RPCs let you call methods on remote machines like local functions.

  1. Add a method to your Cube script:

    public void ChangeColor()
    {
        GetComponent<Renderer>().material.color =
            new Color(Random.value, Random.value, Random.value);
    }
    
  2. Trigger it with an RPC:

    void Update()
    {
        if (Input.GetKeyDown(KeyCode.C))
        {
            networkSync.CallRPC("ChangeColor",
                UCNetwork.MessageReceiver.AllClientsInArea);
        }
    }
    

Pressing C tells the server to broadcast the ChangeColor RPC to all clients in the same area. All cubes change color at once.

Creating a Custom Server

To go beyond the default server:

  • Implement your own connection approval logic (passwords, tokens, account IDs).

  • Use areas to organize players (towns, dungeons, teams).

  • Decide when to spawn objects on behalf of clients vs. the server.

  • Enforce validation: never trust client RPCs or Sync messages without checking ownership and state.

Example:

void ConnectionRequest(ServerNetwork.ConnectionRequestInfo info)
{
    if (info.password == "letmein")
        server.ConnectionApproved(info.id);
    else
        server.ConnectionDenied(info.id);
}

Creating a Custom Client

To build your own client gameplay logic:

  • Instantiate prefabs using ClientNetwork.Instantiate.

  • Add NetworkSync to every networked prefab.

  • Handle ownership with OnGainOwnership / OnLoseOwnership.

  • Use RPCs for discrete actions (shooting, opening doors).

  • Use Sync/LiteSync for continuous data (movement, stats).

Example:

void OnGainOwnership()
{
    // Enable player controls when we own this avatar
    GetComponent<PlayerController>().enabled = true;
}

void OnLoseOwnership()
{
    // Disable controls when no longer the owner
    GetComponent<PlayerController>().enabled = false;
}

Where to Go Next

  • Learn more about networked-objects for continuous synchronization.

  • Explore rpcs for discrete actions.

  • Use areas to filter updates for scalability.

  • See server-best-practices and client-best-practices for production-ready patterns.

Summary

  • Open the Server scene, press Play → server is running.

  • Open the Client scene, press Play → connect to server on port 603.

  • Clients spawn a Player object into Area 1 by default.

  • Use Instantiate to create shared objects, RPCs for events, and Sync for continuous updates.

  • Extend by writing custom server logic and client behaviors.