Get started with Relay
Set up Relay and get started with a sample project.
Read time 3 minutesLast updated 14 hours ago
Read the following sections to learn how to set up a Relay project and how to use the Relay sample project. If you haven’t already, visit Get started with UGS to learn how to work with the Unity Dashboard.
Set up a Relay project
Relay is a PAYG (pay as you go) service with a free tier. If you exceed the free tier monthly usage limit, you must enter payment information to keep full access to Relay and any other services.Prerequisites
To get started with Relay, you need to do the following:Set up Relay
You can set up and manage Relay through the Unity Dashboard:- In the Unity Dashboard, select the Products tab from the sidebar.
- Under Gaming Services > Multiplayer, go to Relay and select Launch.
Link your Relay project in the Unity Editor
- Open your project in the Unity Engine and navigate to Edit > Project Settings.
- From the Project Settings window, go to the Services tab.
- Select Use an existing Unity project ID and link to the Unity Dashboard project displayed in the Setup guide.
- After the project links successfully, you're ready to move on to the next step of the integration process.
Install the Relay package
- In the Unity Editor's Package Manager, select Unity Registry.
- Search for the following package:
- For Unity 2022 LTS and later:
com.unity.services.multiplayer - For earlier versions of Unity:
com.unity.services.relay
- For Unity 2022 LTS and later:
- Select the package, then Install. Refer to Package Manager.
Relay with Netcode for Game Objects
Using Relay with Netcode for GameObjects is a simple use case. Check out Relay with Netcode for GameObjects to learn more.Simple Relay sample
The Simple Relay sample is an example project that exercises the Relay SDK. The project provides a simple user interface (UI) with buttons, and is intended for manual testing of the SDK. To try the sample project, follow the steps below.Import the Simple Relay sample project
- Open a Relay project with the Unity Editor (version 2020.3). If you don’t have a Relay project set up yet, check out Set up a Relay project.
- Open the Package Manager and navigate to the Relay package.
- Expand the Samples section.
- Select Import to import the Simple Relay sample project.
- Now that you have imported the Simple Relay sample project, you can open it as a scene. It's located within the current project under .
Assets/Samples/Relay/1.0.1-pre.3/Simple Relay Sample - Select File > Open Scene.
- Navigate to the Simple Relay sample scene. Continue onto Use the Simple Relay sample to learn how to use it.
Use the Simple Relay sample
- Sign into the Unity Editor.
- Go to Account > Sign in
- Selecting the Sign in button opens the Unity Dashboard in a browser window. Make sure you’re signed into the same account with the Relay-enabled project.
- Link a project to the Simple Relay sample.
- In the Unity Editor, select Edit > Project Settings.
- Select Use an existing Unity project ID.
- Fill in the Organization and Project fields.
- Select Link project ID.
- If successful, your project ID appears under Unity Project ID.
Start the Simple Relay sample
- Select the Play button to start the sample. Refer to The Toolbar.
- Go through and select each of the buttons within the sample in order:
- Sign In (Anonymously) uses Unity’s Anonymous authentication to sign into Relay. This generates a player ID.
- Get Regions lists all the regions in which a Relay server is available.
- Create Relay creates a Relay allocation and returns the host allocation ID.
- Get Join Code generates a join code for the host to share with other players.
- Join Relay joins the Relay allocation and returns a player allocation ID.