🐾PurrNet Docs

Minimal Setup

Run a networked scene in under 5 minutes.

Step 1: Network Manager

Create an empty GameObject in your scene and add a NetworkManager component. This is the heart of PurrNet — it manages connections, prefabs, and rules.

Configure:

  • Network Rules — drag in a preset (ServerStrict is recommended for new projects)
  • Transport — add a UDPTransport component to the same GameObject
  • Network Prefabs — register the prefabs you plan to spawn over the network

Step 2: Your first NetworkBehaviour

PlayerController.cs
using PurrNet;
using UnityEngine;

public class PlayerController : NetworkBehaviour
{
    [SerializeField] private float speed = 5f;

    protected override void OnSpawned(bool asServer)
    {
        if (isOwner)
        {
            // Only the owner gets the camera
            Camera.main.GetComponent<CameraFollow>().SetTarget(transform);
        }
    }

    void Update()
    {
        if (!isOwner) return; // Only owner drives input

        var move = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
        CmdMove(move * speed * Time.deltaTime);
    }

    [ServerRpc(requireOwnership: true)]
    private void CmdMove(Vector3 delta)
    {
        transform.position += delta;
    }
}

Step 3: Host & Connect

Call these from a UI button or Awake:

csharp
// Start as host (server + client on same machine)
networkManager.StartHost();

// Or start as server only
networkManager.StartServer();

// Connect as client
networkManager.Connect("127.0.0.1", 7777);
For local testing without a build: use ParrelSync or Unity's Multiplayer Play Mode package to run multiple editors simultaneously.