Getting Started
This guide walks you through installing GONet, creating your first networked scene, and testing with two connected players. By the end, you will have a working multiplayer prototype running locally.
Prerequisites
Before you begin, make sure your Unity project meets the following requirements:
- 1.Unity 2022 LTS or later -- GONet is tested up through Unity 6. Older versions (2021.3.26+ for GONet v1.3, 2018.3+ for v1.2 and earlier) may work but are not actively supported.
- 2.Enable unsafe code -- Navigate to Edit → Project Settings → Player → Allow 'unsafe' Code and enable the checkbox. GONet uses unsafe code internally for high-performance memory operations.
- 3.Set API compatibility to .NET 4.x -- In the same Player settings, set Api Compatibility Level to .NET 4.x. This is required for certain serialization and async features.
- 4.Optional: Add logging symbols -- For detailed logging during development, add these Scripting Define Symbols in Player settings:
LOG_DEBUG;LOG_INFO;LOG_WARNING;LOG_ERROR;LOG_FATALThese symbols enable GONet's built-in log levels. You can include only the levels you need -- for example, just LOG_WARNING;LOG_ERROR;LOG_FATAL for a quieter console.
Installation
GONet is distributed through the Unity Asset Store. There are three steps to get it into your project:
- 1.Get GONet from the Asset Store -- Visit the GONet listing on the Unity Asset Store and add it to your assets. If you have already purchased it, open the Package Manager in Unity (Window → Package Manager → My Assets) and download it from there.
- 2.Import the package -- Import the GONet package into your project. Unity will compile the scripts automatically. Wait for the compilation to finish before proceeding -- you will see the progress bar disappear in the bottom-right corner of the editor.
- 3.Verify the import -- You should see an Assets/GONet folder in your Project window. If Unity reports any compilation errors, double-check that unsafe code is enabled and the API compatibility level is set to .NET 4.x (see Prerequisites above).
Video walkthrough available -- If you prefer a visual guide, this YouTube tutorial covers installation and basic setup from start to finish.
Your First Networked Scene
With GONet imported, you are ready to create a simple networked scene. This example creates a player cube that synchronizes its position across the network.
Step 1: Add the GONet global prefab
Every GONet scene needs the GONet_GlobalContext prefab. This singleton manages all networking state -- connections, synchronization, and events. Find it at:
Assets/GONet/Resources/GONet/GONet_GlobalContext.prefabDrag it into your startup scene. Alternatively, you can start from the included sample scene which already has everything configured:
Assets/GONet/Sample/GONetSampleScene.unityStep 2: Create a player prefab
Create a new Cube in your scene (GameObject → 3D Object → Cube). This will be your networked player. With the Cube selected, add a GONetParticipant component using the Inspector. This component tells GONet that this GameObject participates in network synchronization.
Step 3: Add a player controller script
Create a new C# script called SimplePlayer and attach it to the Cube. Replace the contents with the following:
using GONet;
using UnityEngine;
public class SimplePlayer : GONetParticipantCompanionBehaviour
{
[GONetAutoMagicalSync]
public Vector3 Position
{
get => transform.position;
set => transform.position = value;
}
public override void OnGONetReady()
{
Debug.Log($"Player ready! Mine: {IsMine}");
}
internal override void UpdateAfterGONetReady()
{
if (!IsMine) return;
float h = Input.GetAxis("Horizontal");
float v = Input.GetAxis("Vertical");
transform.Translate(new Vector3(h, 0, v) * Time.deltaTime * 5f);
}
}Here is what each part does:
- GONetParticipantCompanionBehaviour -- a base class that automatically connects to the GONetParticipant on the same GameObject and provides the IsMine property.
- [GONetAutoMagicalSync] -- marks the Position property for automatic network synchronization. GONet detects changes and replicates them to all other machines.
- OnGONetReady() -- called once the participant is fully initialized on the network and ready to send or receive data.
- UpdateAfterGONetReady() -- a GONet-managed update loop that runs only after networking is ready. More efficient than Unity's built-in Update() because GONet batches these calls internally.
- IsMine -- returns true if the local machine owns this object. Only the owner processes input; remote copies receive position updates automatically through sync.
Step 4: Save as a prefab
Drag the Cube from the Hierarchy into Assets/GONet/Resources/ (or any Resources folder in your project). GONet needs networked prefabs to be in a Resources folder so it can instantiate them across the network. You can remove the Cube from the scene after saving the prefab -- GONet will spawn it at runtime.
Testing Locally
You can test multiplayer locally using two instances: the Unity Editor and a standalone build.
- 1.Press Play in the Unity Editor.
- 2.Press Alt + S to start as the server. The server instance creates the game session and waits for clients.
- 3.Build and run a second instance of the project (File → Build and Run, or use an existing build). In that instance, press Alt + C to connect as a client.
- 4.Move the player on one instance using the arrow keys or WASD. You should see the corresponding cube move on the other instance. The Position property is being synchronized automatically by GONet.
Tip: If you do not see movement on the remote instance, check the Console for connection errors. Make sure both instances are running on the same machine or local network, and that no firewall is blocking the connection.
Building for Deployment
When you are ready to distribute your game, the deployment process depends on your target platform.
Windows
GONet includes batch files that make it easy to start server and client instances:
- 1.Copy Start_CLIENT.bat and Start_SERVER.bat from Assets/StreamingAssets/GONet/ into your build output directory (next to the .exe file).
- 2.Open each .bat file in a text editor and update the executable name to match your build (e.g., replace the default name with MyGame.exe).
- 3.Run Start_SERVER.bat first, then run Start_CLIENT.bat to connect.
Other Platforms
On platforms where batch files are not available, launch two instances of your built application manually. In the first instance, press Alt + S to start as the server. In the second instance, press Alt + C to connect as a client.
Next Steps
You now have a working networked scene with automatic position synchronization. From here, you can explore GONet's features in more depth:
- →Core Concepts -- Understand the authority model, GONetParticipant, GONetBehaviour, and the networking lifecycle.
- →Auto-Magical Sync -- Learn how to synchronize any field or property with quantization, blending, and velocity support.
- →Remote Procedure Calls -- Send targeted messages between server and clients with async/await support.