> ## 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.

<Info>
  **Unity Netcode for GameObjects** is Unity's official high-level networking library, providing a game-centric networking experience.
</Info>

## Video Tutorial

<iframe width="100%" height="400" src="https://www.youtube.com/embed/ydFBvDOaeDw" title="Unity Netcode on PlayFlow Cloud Tutorial" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen />

<Tip>
  Watch the video above for a complete walkthrough of deploying Unity Netcode for GameObjects on PlayFlow Cloud, or follow the written guide below.
</Tip>

## Before We Begin

<Steps>
  <Step title="Prerequisites">
    Ensure you have:

    * An existing Unity Netcode for GameObjects project
    * Unity Netcode for GameObjects package installed
    * NetworkManager configured in your scene
  </Step>

  <Step title="Install PlayFlow SDK">
    Install the PlayFlow SDK via Unity Package Manager:

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

    <Info>
      For detailed instructions, see the [Installation Guide](/guides/installation).
    </Info>
  </Step>

  <Step title="Install Linux Modules">
    Install **Linux Build Support** modules in Unity Hub for server builds.

    <Info>
      See [Unity Modules Setup](/guides/unity-modules) for your Unity version.
    </Info>
  </Step>
</Steps>

## Configure Netcode for PlayFlow

<Steps>
  <Step title="Configure NetworkManager">
    Ensure your NetworkManager has:

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

  <Step title="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.
  </Step>

  <Step title="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

    <Info>
      Unity Transport handles most server configuration automatically when running in headless mode.
    </Info>
  </Step>
</Steps>

## Deploy to PlayFlow

<Steps>
  <Step title="Create PlayFlow Account">
    Go to [PlayFlow Cloud](https://app.playflowcloud.com/) and sign up or log in.
  </Step>

  <Step title="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
  </Step>

  <Step title="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
  </Step>

  <Step title="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.

    <Info>
      The build process takes a few minutes. You'll see a success message when complete.
    </Info>
  </Step>
</Steps>

## Configure PlayFlow

<Steps>
  <Step title="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
  </Step>

  <Step title="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**.

    <Info>
      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.
    </Info>
  </Step>

  <Step title="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.
    </Warning>
  </Step>
</Steps>

## Next Steps

<CardGroup cols={3}>
  <Card title="Lobby System" icon="users" href="/unity/lobby-overview">
    Integrate Unity Lobby Service with PlayFlow
  </Card>

  <Card title="Matchmaking" icon="shuffle" href="/unity/matchmaking">
    Add matchmaking to your Netcode game
  </Card>

  <Card title="Server Management" icon="server" href="/unity/game-servers">
    Advanced server management techniques
  </Card>
</CardGroup>

## Success!

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

## Common Issues

<AccordionGroup>
  <Accordion title="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>

  <Accordion title="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>

  <Accordion title="High latency or packet loss">
    * Adjust NetworkTickRate based on your needs
    * Configure Unity Transport reliability settings
    * Use PlayFlow's server monitoring to identify issues
  </Accordion>
</AccordionGroup>
