> ## Documentation Index
> Fetch the complete documentation index at: https://docs.playflowcloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Quick Start - Unity Netcode

> Deploy your Unity Netcode for GameObjects server on PlayFlow Cloud

# Deploy Your Unity Netcode Server

This guide assumes you already have a Unity Netcode for GameObjects project and are ready to deploy it on PlayFlow Cloud.

> [!NOTE]
>
> **Unity Netcode for GameObjects** is Unity's official high-level networking library, providing a game-centric networking experience.

## Video Tutorial

[Unity Netcode on PlayFlow Cloud Tutorial](https://www.youtube.com/embed/ydFBvDOaeDw)

> [!TIP]
>
> Watch the video above for a complete walkthrough of deploying Unity Netcode for GameObjects on PlayFlow Cloud, or follow the written guide below.

## Before We Begin

**1. Prerequisites**

Ensure you have:

* An existing Unity Netcode for GameObjects project
* Unity Netcode for GameObjects package installed
* NetworkManager configured in your scene

**2. Install PlayFlow SDK**

Install the PlayFlow SDK via Unity Package Manager:

```
https://github.com/PlayFlowCloud/PlayFlow-Multiplayer-Unity-SDK.git
```

> [!NOTE]
>
> For detailed instructions, see the [Installation Guide](https://docs.playflowcloud.com/guides/installation.md).

**3. Install Linux Modules**

Install **Linux Build Support** modules in Unity Hub for server builds.

> [!NOTE]
>
> See [Unity Modules Setup](https://docs.playflowcloud.com/guides/unity-modules.md) for your Unity version.

## Configure Netcode for PlayFlow

**1. Configure NetworkManager**

Ensure your NetworkManager has:

* Unity Transport component attached
* Default port set (usually `7777`)
* Network Prefabs configured

**2. Add Server Auto-Start**

Create a script to auto-start the server in headless builds:

```csharp theme={null}
using Unity.Netcode;
using UnityEngine;

public class PlayFlowNetcodeStarter : MonoBehaviour
{
    void Start()
    {
        #if UNITY_SERVER || UNITY_HEADLESS
        NetworkManager.Singleton.StartServer();
        Debug.Log("Unity Netcode server started on PlayFlow");
        #endif
    }
}
```

Attach this script to a GameObject in your scene.

**3. Configure Transport**

For the Unity Transport component on NetworkManager:

* Keep the default port (`7777`)
* Server will automatically bind to `0.0.0.0` in headless builds

> [!NOTE]
>
> Unity Transport handles most server configuration automatically when running in headless mode.

## Deploy to PlayFlow

**1. Create PlayFlow Account**

Go to [PlayFlow Cloud](https://app.playflowcloud.com/) and sign up or log in.

**2. Create Organization & Project**

1. Create an Organization (new orgs start on the **Free** plan; upgrade to **Pro** anytime)
2. Create a new project
3. Select **Unity** as the game engine

**3. Link PlayFlow SDK**

1. In PlayFlow dashboard, go to **API Keys**
2. Copy your **PlayFlow API Key**
3. In Unity, open **PlayFlow → PlayFlow Cloud**
4. Paste the API key

**4. Upload Your Server**

In the PlayFlow window:

1. Select your game scene
2. Click **Upload Server**

PlayFlow automatically builds and uploads a headless Linux server.

> [!NOTE]
>
> The build process takes a few minutes. You'll see a success message when complete.

## Configure PlayFlow

**1. Configure Network Port**

In PlayFlow dashboard:

1. Go to **Configuration** → **Network Ports**
2. Click **Add Port**
3. Enter:
   * **Port Name**: `netcode_game`
   * **Port Number**: `7777`
   * **Protocol**: **UDP**
4. Save configuration

**2. Create Server**

1. Go to **Servers** tab
2. Click **Create Server**
3. Select your uploaded build
4. Choose a **region** (required) and a compute size
5. Click **Create Server**

Wait for status to change to **Running**.

> [!NOTE]
>
> On the **Free** plan, servers run on the `small` compute size with a 1-hour maximum lifetime, and you can have 1 active server at a time. Choosing a different compute size and longer TTLs (up to 24 hours) requires the **Pro** plan.

**3. Connect Your Client**

1. Click **Details** on your running server
2. Copy the **Host** and **External Port** for your UDP port (these come from the `network_ports[]` array in the server API response — read them at runtime, never hardcode)
3. In your Unity client:

```csharp theme={null}
using Unity.Netcode;
using Unity.Netcode.Transports.UTP;

void ConnectToPlayFlowServer(string host, ushort externalPort)
{
    var transport = NetworkManager.Singleton.GetComponent<UnityTransport>();
    transport.SetConnectionData(host, externalPort);
    NetworkManager.Singleton.StartClient();
}
```

Pass the **Host** and **External Port** from PlayFlow into this method.

> [!WARNING]
>
> Do **not** connect to port `7777`. `7777` is the internal port your server binds to inside the container. PlayFlow maps UDP through a proxy and allocates a different **external port** for clients. Always read the host and external port from the server's `network_ports[]` response (or the dashboard **Details** panel) at runtime — they change per server.

## Next Steps

> [card] [Lobby System](https://docs.playflowcloud.com/unity/lobby-overview.md)
>
> Integrate Unity Lobby Service with PlayFlow

> [card] [Matchmaking](https://docs.playflowcloud.com/unity/matchmaking.md)
>
> Add matchmaking to your Netcode game

> [card] [Server Management](https://docs.playflowcloud.com/unity/game-servers.md)
>
> Advanced server management techniques

## Success!

Your Unity Netcode server is now running on PlayFlow Cloud! Clients can connect using the server's public IP and port.

## Common Issues

> [accordion] NetworkManager is null
>
> Ensure NetworkManager exists in your scene and that you're not trying to access it too early in the Start() method.

> [accordion] Clients stuck on connecting
>
> * Verify UDP port 7777 is configured in PlayFlow
> * Check that server is binding to 0.0.0.0 not localhost
> * Ensure firewall rules allow UDP traffic

> [accordion] High latency or packet loss
>
> * Adjust NetworkTickRate based on your needs
> * Configure Unity Transport reliability settings
> * Use PlayFlow's server monitoring to identify issues


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.