# Table of Contents - [Welcome | ObjectNet ](#welcome-objectnet-) - [Full API Reference | ObjectNet ](#full-api-reference-objectnet-) - [Installing | ObjectNet ](#installing-objectnet-) - [About | ObjectNet ](#about-objectnet-) - [System requirements | ObjectNet ](#system-requirements-objectnet-) - [Object Updates | ObjectNet ](#object-updates-objectnet-) - [Network Transport | ObjectNet ](#network-transport-objectnet-) - [Step by Step | ObjectNet ](#step-by-step-objectnet-) - [DataStream | ObjectNet ](#datastream-objectnet-) - [Providers Scripts | ObjectNet ](#providers-scripts-objectnet-) - [Network Components | ObjectNet ](#network-components-objectnet-) - [Step 1 - Configuring Scene | ObjectNet ](#step-1-configuring-scene-objectnet-) - [Network Transport | ObjectNet ](#network-transport-objectnet-) - [Server Mode | ObjectNet ](#server-mode-objectnet-) - [Network Events | ObjectNet ](#network-events-objectnet-) - [Delivery Mode | ObjectNet ](#delivery-mode-objectnet-) - [Connections | ObjectNet ](#connections-objectnet-) - [Network Prefabs | ObjectNet ](#network-prefabs-objectnet-) - [Client Connection | ObjectNet ](#client-connection-objectnet-) - [Network Manager | ObjectNet ](#network-manager-objectnet-) - [Network DataBase | ObjectNet ](#network-database-objectnet-) - [Movement Prediction | ObjectNet ](#movement-prediction-objectnet-) - [Remote Controls | ObjectNet ](#remote-controls-objectnet-) - [Other Settings | ObjectNet ](#other-settings-objectnet-) - [Server Connection | ObjectNet ](#server-connection-objectnet-) - [Enable Login | ObjectNet ](#enable-login-objectnet-) - [Player Prefab | ObjectNet ](#player-prefab-objectnet-) - [Step 3 - Network Prefabs | ObjectNet ](#step-3-network-prefabs-objectnet-) - [Step 2 - Defining a Database | ObjectNet ](#step-2-defining-a-database-objectnet-) - [Step 5 - Spawn Position | ObjectNet ](#step-5-spawn-position-objectnet-) - [Step 4 - Player Prefab | ObjectNet ](#step-4-player-prefab-objectnet-) - [Step 6 - Setup Server | ObjectNet ](#step-6-setup-server-objectnet-) - [Step 8 - Compiling Client's | ObjectNet ](#step-8-compiling-client-s-objectnet-) - [Step 7 - Compiling Server | ObjectNet ](#step-7-compiling-server-objectnet-) - [Fundamentals | ObjectNet ](#fundamentals-objectnet-) - [Step 9 - Running | ObjectNet ](#step-9-running-objectnet-) - [Step 10 - Next Steps | ObjectNet ](#step-10-next-steps-objectnet-) - [Network Prefabs | ObjectNet ](#network-prefabs-objectnet-) - [Registering Prefab | ObjectNet ](#registering-prefab-objectnet-) - [Synchronization Options | ObjectNet ](#synchronization-options-objectnet-) - [Prefab Scripts | ObjectNet ](#prefab-scripts-objectnet-) - [Child Objects | ObjectNet ](#child-objects-objectnet-) - [Prefab Scripts ( Remote Input ) | ObjectNet ](#prefab-scripts-remote-input-objectnet-) - [Network Events Manager | ObjectNet ](#network-events-manager-objectnet-) - [Script Variables | ObjectNet ](#script-variables-objectnet-) - [Global Events | ObjectNet ](#global-events-objectnet-) - [Custom Events | ObjectNet ](#custom-events-objectnet-) - [Network Debugger | ObjectNet ](#network-debugger-objectnet-) - [Network Behaviour | ObjectNet ](#network-behaviour-objectnet-) - [Network Methods | ObjectNet ](#network-methods-objectnet-) - [Ownership | ObjectNet ](#ownership-objectnet-) - [Despawn Objects | ObjectNet ](#despawn-objects-objectnet-) - [Playing Audio | ObjectNet ](#playing-audio-objectnet-) - [Network Variables | ObjectNet ](#network-variables-objectnet-) - [Spawn and Despawn | ObjectNet ](#spawn-and-despawn-objectnet-) - [Manual Animations | ObjectNet ](#manual-animations-objectnet-) - [Spawn Objects | ObjectNet ](#spawn-objects-objectnet-) - [In-Scene Objects | ObjectNet ](#in-scene-objects-objectnet-) - [NetworkManager Functions | ObjectNet ](#networkmanager-functions-objectnet-) - [Spawn Player Manually | ObjectNet ](#spawn-player-manually-objectnet-) - [Scene Managment | ObjectNet ](#scene-managment-objectnet-) - [Common Functions | ObjectNet ](#common-functions-objectnet-) - [Respawn Player | ObjectNet ](#respawn-player-objectnet-) - [Sending Events | ObjectNet ](#sending-events-objectnet-) - [Starting and Stopping Network | ObjectNet ](#starting-and-stopping-network-objectnet-) - [Importing Examples | ObjectNet ](#importing-examples-objectnet-) - [Converting Materials | ObjectNet ](#converting-materials-objectnet-) - [Relay Example | ObjectNet ](#relay-example-objectnet-) - [Common Functions | ObjectNet ](#common-functions-objectnet-) - [Example Scenes | ObjectNet ](#example-scenes-objectnet-) - [Manual Scene Load | ObjectNet ](#manual-scene-load-objectnet-) - [Third Party Assets | ObjectNet ](#third-party-assets-objectnet-) - [Docker | ObjectNet ](#docker-objectnet-) - [Dissonance Voice Chat | ObjectNet ](#dissonance-voice-chat-objectnet-) - [Lobby Example | ObjectNet ](#lobby-example-objectnet-) - [Authoritative Example | ObjectNet ](#authoritative-example-objectnet-) - [Building Server | ObjectNet ](#building-server-objectnet-) - [Custom DataStream | ObjectNet ](#custom-datastream-objectnet-) - [Building Server | ObjectNet ](#building-server-objectnet-) - [Unity Transport | ObjectNet ](#unity-transport-objectnet-) - [Building Client | ObjectNet ](#building-client-objectnet-) - [Sending Global Events | ObjectNet ](#sending-global-events-objectnet-) - [Building Client | ObjectNet ](#building-client-objectnet-) - [Steam Transport | ObjectNet ](#steam-transport-objectnet-) - [Unity Dedicated Server | ObjectNet ](#unity-dedicated-server-objectnet-) - [Custom Behaviour | ObjectNet ](#custom-behaviour-objectnet-) - [SmoothSync | ObjectNet ](#smoothsync-objectnet-) - [Building Server | ObjectNet ](#building-server-objectnet-) - [Building Client | ObjectNet ](#building-client-objectnet-) --- # Welcome | ObjectNet **Thank you** for your purchase of the most powerful and flexible multiplayer solution on the Asset Store. ObjectNet was designed to be easy and simple, nonetheless, is at the same time highly powerful and can be used on any type of project. We are very proud of our product, and if you have any comments or suggestions feel free to contact us by email admin@onlineobject.net [NextAbout](https://onlineobject.gitbook.io/objectnet/about) --- # Full API Reference | ObjectNet For a complete and detailed overview of all available classes, methods, properties, and interfaces in ObjectNet, refer to the official API documentation: 👉 [View Full API Reference](https://onlineobject.net/objectnet/docs/api/html/N-com.onlineobject.objectnet.htm) This reference includes: * All core namespaces * Public methods and properties * Inheritance structure and member summaries Use it as a technical companion when building advanced systems or exploring deeper integrations with ObjectNet. [PreviousAbout](https://onlineobject.gitbook.io/objectnet/about) [NextSystem requirements](https://onlineobject.gitbook.io/objectnet/getting-started/system-requirements) Last updated 6 months ago --- # Installing | ObjectNet This topic will cover how to install ObjectNet on your project. 1. After acquiring the ObjectNet go to the Unity package manager. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem1.png&width=768&dpr=4&quality=100&sign=a8c0815a&sv=2) 1. Locate ObjectNet package and click to download ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem2.png&width=768&dpr=4&quality=100&sign=7f6340cd&sv=2) 1. After download was finished click on import ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem3.png&width=768&dpr=4&quality=100&sign=758ea908&sv=2) 1. On the opened window got to the right bottom corner and press Import ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem213.png&width=768&dpr=4&quality=100&sign=12d28225&sv=2) Done, you have already ObjectNet on your project. [PreviousSystem requirements](https://onlineobject.gitbook.io/objectnet/getting-started/system-requirements) [NextStep by Step](https://onlineobject.gitbook.io/objectnet/getting-started/quickstart) --- # About | ObjectNet ObjectNet is an event solution based, created to make it easy to create and maintain multiplayer solutions. The core engine used by ObjectNet was designed to be agnostic, this means that ObjectNet can work independently from game or application logic. Your game or application could be designed for any purpose and ObjectNet shall work seamlessly. Created by a team with decades of experience in network applications and software communication, ObjectNet is pretty well-designed and reliable. [PreviousWelcome](https://onlineobject.gitbook.io/objectnet) [NextFull API Reference](https://onlineobject.gitbook.io/objectnet/full-api-reference) --- # System requirements | ObjectNet ObjectNet requirements will depend on the project where he will be used, in short, ObjectNet uses a few resources from the system. Nonetheless, depending on how your game was designed, this could mean more or less computation and memory. A game with a few elements to be synchronized can run on ordinary hardware, on the other hand, how many elements you need to synchronize, more CPU systems will be required. ObjectNet has a pretty smart system to detect and send events only when \*changes occur, this reduces the amount of data and computation required to keep things up to date. \*Smart detection system only applies to events and data controlled by ObjectNet, for events raised or sent manually by the developer, ObjectNet will not take and measure. [PreviousFull API Reference](https://onlineobject.gitbook.io/objectnet/full-api-reference) [NextInstalling](https://onlineobject.gitbook.io/objectnet/getting-started/installing) --- # Object Updates | ObjectNet Object Update is the way ObjectNet keeps objects updated, this is a special core event used to send and receive all updates of any NetworkPrefab. * * * By default, object updates can include the following information: * Object Position * Object Rotation * Object Scale * Animation Status * Particles Status * Variables ( only for **Network Objects** ) [PreviousNetwork Prefabs](https://onlineobject.gitbook.io/objectnet/general/fundamentals/network-prefabs) [NextDelivery Mode](https://onlineobject.gitbook.io/objectnet/general/fundamentals/delivery-mode) --- # Network Transport | ObjectNet Network Transport is the way how ObjectNet use to communicate with other network peers. ObjectNet has its embedded transport system called OnlineObjectTransport which is a light-way implementation of TCP and UDP sockets. ObjectNet also accepts "Unity Transport System" in replace of OnlineObjectTransport ( see how to install Unity Transport [Unity Transport](https://onlineobject.gitbook.io/objectnet/extras/unity-transport) ). Additionally, you can also implement any other transport system such as Epic, Steam, or your custom system by using the interfaces provided by ObjectNet API. * * * The following drawing illustrates how ObjectNet abstracts its internal behavior from the configured transport system. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fcontent.gitbook.com%2Fcontent%2FNG75ky1pR1kRokWLRnzy%2Fblobs%2FeIA48udAnC3qx1rhGm9d%2FNewItem11.png&width=768&dpr=4&quality=100&sign=2ef6fab6&sv=2) The logic gate layer isolates ObjectNet internal logic from the transport system. This allows the system to interchange messages using any transport system that implements needed interfaces. [PreviousDelivery Mode](https://onlineobject.gitbook.io/objectnet/general/fundamentals/delivery-mode) [NextDataStream](https://onlineobject.gitbook.io/objectnet/general/fundamentals/datastream) Last updated 7 months ago --- # Step by Step | ObjectNet [Step 1 - Configuring Scene](https://onlineobject.gitbook.io/objectnet/getting-started/quickstart/step-1-configuring-scene) [Step 2 - Defining a Database](https://onlineobject.gitbook.io/objectnet/getting-started/quickstart/step-2-defining-a-database) [Step 3 - Network Prefabs](https://onlineobject.gitbook.io/objectnet/getting-started/quickstart/step-3-network-prefabs) [Step 4 - Player Prefab](https://onlineobject.gitbook.io/objectnet/getting-started/quickstart/step-4-player-prefab) [Step 5 - Spawn Position](https://onlineobject.gitbook.io/objectnet/getting-started/quickstart/step-5-spawn-position) [Step 6 - Setup Server](https://onlineobject.gitbook.io/objectnet/getting-started/quickstart/step-6-setup-server) [Step 7 - Compiling Server](https://onlineobject.gitbook.io/objectnet/getting-started/quickstart/step-7-compiling-server) [Step 8 - Compiling Client's](https://onlineobject.gitbook.io/objectnet/getting-started/quickstart/step-8-compiling-clients) [Step 9 - Running](https://onlineobject.gitbook.io/objectnet/getting-started/quickstart/step-9-running) [Step 10 - Next Steps](https://onlineobject.gitbook.io/objectnet/getting-started/quickstart/step-10-next-steps) [PreviousInstalling](https://onlineobject.gitbook.io/objectnet/getting-started/installing) [NextStep 1 - Configuring Scene](https://onlineobject.gitbook.io/objectnet/getting-started/quickstart/step-1-configuring-scene) --- # DataStream | ObjectNet ObjectNet provides the facility to send and receive simple and complex structures over the network. This structure is a class that needs to implement IDataStream interface. ObjectNet has already the following types : * Int16 : Int16Stream * UInt16 : UInt16Stream * Int32 : Int32Stream * UInt32 : UInt32Stream * float : FloatStream * double : DoubleStream * bool : BooleanStream * string : StringStream * Color : ColorStream * byte : ByteStream * sbyte : SByteStream * byte\[\] : ByteArrayStream * Vector2 : Vector2Stream * Vector3 : Vector3Stream * Vector4 : Vector4Stream * Quaternion : QuaternionStream * Matrix4x4 : Matrix4x4Stream The main idea of DataStream is to write and read data without the need to write on each place, you can use some DataStream and encapsulate how much data you need. To implement your own DataStream you can check the API document on NetworkEntity class ( see [Custom DataStream](https://onlineobject.gitbook.io/objectnet/advance/custom-datastream) ). [PreviousNetwork Transport](https://onlineobject.gitbook.io/objectnet/general/fundamentals/network-transport) [NextProviders Scripts](https://onlineobject.gitbook.io/objectnet/general/fundamentals/providers-scripts) --- # Providers Scripts | ObjectNet ObjectNet introduces the concept of Provider Scripts, provider script is scripts that allow to provide any input information to ObjectNet. This means that every time that you can input or override any ObjectNet behavior, this will be made by some Provider Script. There are two types of providers : * IInformationProvider \-This provider covers almost all cases and is used to provide any information to the system. * IInputProvider \-This provider is used only to provide network Inputs ( see [Remote Controls](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/remote-controls) ). ObjectNet provides an example of each information provider in the following example folder. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem145.png&width=768&dpr=4&quality=100&sign=fb833cdf&sv=2) [PreviousDataStream](https://onlineobject.gitbook.io/objectnet/general/fundamentals/datastream) [NextNetwork Components](https://onlineobject.gitbook.io/objectnet/general/network-components) --- # Network Components | ObjectNet [Network Manager](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager) [Network Prefabs](https://onlineobject.gitbook.io/objectnet/general/network-components/network-prefabs) [Network Events Manager](https://onlineobject.gitbook.io/objectnet/general/network-components/network-events-manager) [Network Debugger](https://onlineobject.gitbook.io/objectnet/general/network-components/network-debugger) [PreviousProviders Scripts](https://onlineobject.gitbook.io/objectnet/general/fundamentals/providers-scripts) [NextNetwork Manager](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager) --- # Step 1 - Configuring Scene | ObjectNet You will need to place some objects on your scene to work with ObjectNet, each object has its own purpose, but in this example, we will keep on basic and put only NetworkManager. To know more about NetworkManager read the [Network Manager](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager) section, for now, let's keep on our step by-step. Drag NetworkPrefab to you current Scene. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem229.png&width=768&dpr=4&quality=100&sign=7b9ed192&sv=2) Once you placed NetworkManager on your scene you will need to configure it. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem230.png&width=768&dpr=4&quality=100&sign=31d12184&sv=2) [PreviousStep by Step](https://onlineobject.gitbook.io/objectnet/getting-started/quickstart) [NextStep 2 - Defining a Database](https://onlineobject.gitbook.io/objectnet/getting-started/quickstart/step-2-defining-a-database) --- # Network Transport | ObjectNet NetworkTransport is the logic used to send and receive messages between each network node in-game. ObjectNet brings with it its own embedded transport system called OnlineObjectTransport, and also native support Unity Transport system. Modifying Transport[](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/network-transport#modifying-transport) 1. To select another transport system click on the eye icon located on the right side of NetworkManager 1. A new "Transport Database" window shall appear. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fcontent.gitbook.com%2Fcontent%2FNG75ky1pR1kRokWLRnzy%2Fblobs%2FsiwpI8Udg521tIfLn9b6%2FNewItem21.png&width=768&dpr=4&quality=100&sign=e37a85b5&sv=2) 1. Click on the green selector to change the selected transport system. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fcontent.gitbook.com%2Fcontent%2FNG75ky1pR1kRokWLRnzy%2Fblobs%2FKc90g0BVqzHO6xhS5GZC%2FNewItem23.png&width=768&dpr=4&quality=100&sign=8f01bb17&sv=2) Creating custom Transport System[](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/network-transport#creating-custom-transport-system) ObjectNet provides the possibility to anyone create and use their own Transport System or implement any 3-part transport system. To create a new transport system, you shall implement a minimum of 2 classes inherited from the following interfaces. * ITransportClient Provides an implementation of connection from the client perspective. * ITransportServer Provides an implementation of connection from the server perspective. The both interfaces inherited from ITransport which has the signature on needed methods to be implemented. You can use as a reference the already contained Transport Systems. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem25.png&width=768&dpr=4&quality=100&sign=1c18ccb6&sv=2) **ClientEmbedded**, **ServerEmbedded** and **TransportEmbedded** is the wrapper of OnlineObjectTransport system to work with ObjectNet. **UnityClient, UnityServer** and **UnityTransport** is the wrapper of UnityTransport system to work with ObjectNet. You can use any of them as a reference to implement your transport system. Registering custom Transport System[](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/network-transport#registering-custom-transport-system) 1. To select another transport system click on the eye icon located on the right side of NetworkManager 1. A new "Transport Database" window shall appear. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem21.png&width=768&dpr=4&quality=100&sign=b42060f2&sv=2) 1. The following fields must be filled * Transport Name : * The literal name of the transport system * Server Class : * Name space and class which implements ITransportServer interface. * Client Class * Name space and class which implements ITransportClient interface. 1. Click on Register button ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem26.png&width=768&dpr=4&quality=100&sign=404148c9&sv=2) [PreviousNetwork DataBase](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/network-database) [NextServer Mode](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/server-mode) --- # Server Mode | ObjectNet ObjectNet allows you to design your game in different approaches. ObjectNet server can run in the most popular design modes, currently, ObjectNet can run on the following modes: \-Embedded -Relay -Authoritative -Client Only ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem29.png&width=768&dpr=4&quality=100&sign=3088cda&sv=2) Embedded Mode[](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/server-mode#embedded-mode) Embedded mode is a mode where one player starts a server at the same time when he will also be a player. The following design illustrates how this works from a topology point of view. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem31.png&width=768&dpr=4&quality=100&sign=8ca61601&sv=2) This mode allows to any player be a server of the game, at the same time that they can be another player. This means that when a player starts a server he will always enter the game being another player. To use the Embedded mode you must ensure that the "Embedded" option is selected on NetworkManager. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem30.png&width=768&dpr=4&quality=100&sign=54bd85dc&sv=2) Relay Mode[](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/server-mode#relay-mode) Relay mode is a mode where a server works only to redirect communication between players. This mode is pretty useful to allow players on a private network to play online multiplayer games on a dedicated server host. Nonetheless, in this mode, one player needs to execute all game logic since the server only works to redirect communication. This mode is especially useful to allow players behind firewalls to play online games. On requirement to allow Relay mode is that server must be on a public network accessible to all players. The following design illustrates how this works from a topology point of view. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem35.png&width=768&dpr=4&quality=100&sign=39d05cfd&sv=2) To use Relay mode you must ensure that the "Relay" option is selected on NetworkManager. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem36.png&width=768&dpr=4&quality=100&sign=e928e34a&sv=2) Authoritative Mode[](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/server-mode#authoritative-mode) Authoritative mode is a mode where all game logic and physics run on the server and the client doesn't make any decision regarding the game. Authoritative mode is the more trusted way to run the game without suffering from cheating, nonetheless, is high CPU and memory expensive since a copy of the game runs on the server. In Authoritative mode, each player will send his information to the server, server will execute all logic and decisions and send the real status of the game back to the players. The following drawing illustrates how the Authoritative server works. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem47.png&width=768&dpr=4&quality=100&sign=d23d92&sv=2) In this scenario, all players send their information to the server, and the server processes all physics and game logic and sends the current status of the game back to all players. To use the Authoritative mode you must ensure that the "Authoritative" option is selected on NetworkManager. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem48.png&width=768&dpr=4&quality=100&sign=177d3ab1&sv=2) Client Only[](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/server-mode#client-only) Client Only is a mode that does not allow to any player run a server over any hypothesis. Client Only mode must be used when you have an official and your game build not offer the possibility to run a LAN or personal server. In Client Only mode, players must have a server to connect always, nonetheless, you can also provide a copy of your server to be hosted by clients, but needs to be a separate build of Authoritative or Relay modes. To use Client Only mode you must ensure that the "Client Only" option is selected on NetworkManager. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem49.png&width=768&dpr=4&quality=100&sign=9a270c&sv=2) * * * Enable NAT Traversal[](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/server-mode#enable-nat-traversal) NAT Traversal allows players to run the game server in their own internal network and be visible to players out of their own internal LAN. When players run the game on their internal network ( by how TCP and UDP are building) players out of this network are unable to reach the machine where the game is running. The following drawing illustrates a player out of the internal network trying to reach the server where the server is running. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem32.png&width=768&dpr=4&quality=100&sign=42b33c4e&sv=2) Even if the Unknown Player knows the router IP Address, they are unable to reach machine 192.168.1.11 where the game server is running. You can Enable Nat Traversal by checking the option on NetworkManager. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem34.png&width=768&dpr=4&quality=100&sign=7190eb78&sv=2) When NAT Traversal is enabled, the system will try to open the game port used to accept client connections on the server. The system will map the Server Player port in the router targeting the same port on the router, this means that when some player out of the internal network tries to connect to the public IP on the port used by Server Player, the communication will be redirected to the machine where the server is running. The following drawing illustrates how NAT Traversal works. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem42.png&width=768&dpr=4&quality=100&sign=b3ed1243&sv=2) This tells the router that redirect communication from an unknown player to IP 192.168.1.11 and vice-versa. In this mode, players can run the server on their internal network and accept players on the other network to play on the same server. [PreviousNetwork Transport](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/network-transport) [NextConnections](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/connections) --- # Network Events | ObjectNet Network Event is the base of all ObjectNet communication systems, this means that anything will happen based on events. * * * Question : But, what is "event" by definition? Answer : An event happens on an instance of a game ( Server or Client ) and should be notified to other members in the same context. * * * The following drawing illustrates how events work during a game session. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fcontent.gitbook.com%2Fcontent%2FNG75ky1pR1kRokWLRnzy%2Fblobs%2FjWZ16WmVMl2asW5LMEth%2FNewItem27.png&width=768&dpr=4&quality=100&sign=f2fa626c&sv=2) In a basic game architecture, some client or server sends an event destined for one or more players, and when this event arrives the server or player will execute some action. * * * This simple approach provides a powerful mechanism to isolate each action in its context and remove any horizontal dependency from any object or context status. [PreviousFundamentals](https://onlineobject.gitbook.io/objectnet/general/fundamentals) [NextNetwork Prefabs](https://onlineobject.gitbook.io/objectnet/general/fundamentals/network-prefabs) --- # Delivery Mode | ObjectNet [](https://onlineobject.gitbook.io/objectnet/general/fundamentals/delivery-mode#reliable-message) Reliable Message ----------------------------------------------------------------------------------------------------------------------- ObjectNet can deliver messages in a reliable way, this means that the Transport Layer will ensure that the message arrives on the network peer. * * * Normally, this message is sent over a TCP network nonetheless, this may depend on transport layer implementation and can use another protocol such as **reliable UDP** to ensure delivery. * * * This method is commonly used for punctual events that will not be sent twice, for example : * Player is death * Player was spawned * Object was picked * Etc... * * * For messages and events that will be repeated all the time, we suggest using the Unreliable method. * * * [](https://onlineobject.gitbook.io/objectnet/general/fundamentals/delivery-mode#unreliable-message) Unreliable Message --------------------------------------------------------------------------------------------------------------------------- ObjectNet can deliver messages in an unreliable way, which means that the Transport Layer will not ensure that the message arrives on the network peer. * * * Normally, this message is always sent over the UDP network. This method is commonly used for punctual events that will be repeated all the time, for example : * Player position * Player rotation * Player input controls * Etc... The reason why these messages are sent all the time is because Unreliable messages are considerably faster than Reliable messages. * * * An unreliable message does not guarantee that each message will arrive on each peer, this is the reason why messages are sent at a frequency rate because not matter if one message is lost because another message will be sent. [PreviousObject Updates](https://onlineobject.gitbook.io/objectnet/general/fundamentals/object-updates) [NextNetwork Transport](https://onlineobject.gitbook.io/objectnet/general/fundamentals/network-transport) Last updated 7 months ago --- # Connections | ObjectNet ObjectNet uses two connections to work, a Server connection and a Client connection. The server connection is the network instance that runs on the server side to handle all connected clients, on the other hand, the client connection is the entity used to enter into a game as invited. Server Connection : TCP/UDP Socket used on the server side to accept all incoming data on the server side. Client Connection : TCP/UDP connection used to enter into a server as client. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem57.png&width=768&dpr=4&quality=100&sign=cab7e2d5&sv=2) Server Connection is a mode running on instances directly as server, this option shall be used on build to run server only on Authoritative or Relay server modes. This option can also be used to run a server on any mode designed by the developer. Server mode allow to select how to listen for incoming connections over network, depending how you host you server you may need a different type of binding ( see [Server Connection](https://onlineobject.net/objectnet/docs/manual/ServerConnection.html) ) ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem108.png&width=768&dpr=4&quality=100&sign=e41fb852&sv=2) Client Connection is a mode running on instances directly as client, this option shall be used on game compiled to run client-only instances. A game compiled with Client Connection needs a server to connect to. Client connections allow to statically or dynamic select the IP address where server is located ( see [Client Connection](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/connections/client-connection) ) ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem110.png&width=768&dpr=4&quality=100&sign=ca51fbfd&sv=2) Manual Mode is a mode used to let the client decide which mode he wishes to run after the game starts. This option shall be used when the user needs to run the Server on the Client depending on how he wishes to run, is commonly used to run embedded mode where the same player is Server and Client at the same time. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem60.png&width=768&dpr=4&quality=100&sign=ff60cd3b&sv=2) Connect On Start[](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/connections#connect-on-start) The option "Connect on Start" starts the socket connection automatically when the game is started. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem109.png&width=768&dpr=4&quality=100&sign=27c99c9f&sv=2) This option is useful and mandatory when a dedicated server is built for Authoritative and Relay modes, otherwise, the server will not be started. Auto Reconnect[](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/connections#auto-reconnect) ObjectNet allows to clients auto-reconnect on the server when the connection is lost. This option can be enabled by checking the "Auto Reconnect" option. When activated, the client will try to reconnect at the server after the time defined on the "Reconnection Interval" configuration. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem62.png&width=768&dpr=4&quality=100&sign=63c82ee1&sv=2) Once disconnection is detected on the client side, the system will wait the amount of time defined on "Reconnection Interval" before trying to reconnect, and in case of failure will try this again up to reconnecting is established.. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem64.png&width=768&dpr=4&quality=100&sign=be713fb7&sv=2) During the re-connection procedure, the system will try to reconnect a certain number of times before stopping re-connection, this can be configured on the "Reconnection Attempts" slider. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem65.png&width=768&dpr=4&quality=100&sign=3171102a&sv=2) Don't Block UI[](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/connections#dont-block-ui) The option "Don't Block UI" starts the socket connection into a separate coroutine to avoid blocking user interact operations. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem111.png&width=768&dpr=4&quality=100&sign=2128a78&sv=2) This option should be used if some connection process UI will be displayed to the user, otherwise, UI will freeze while the connection process is in progress. Detect server restart[](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/connections#detect-server-restart) ObjectNet provides a facility to clients detect when the server is restarted. This can be useful to finish the game on the client side when the client reconnects after the server is restarted. ObjectNet can bring the player back restoring all player status after the connection is the player reconnects after being released from the server side, nonetheless, this can't be done if the server restarts due to the fact that the server lost all game status. In this case, the client needs to leave the match is a server restart if detected. You can Detect server restart by checking the option on NetworkManager. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem66.png&width=768&dpr=4&quality=100&sign=8a10c45d&sv=2) When activated, an event will be raised when a server restart is detected. This event can be caught on NetworkEventsManager or by the API method OnServerRestarted on NetworkTransport class ( see API reference to more information's ). Disconnect Detection[](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/connections#disconnect-detection) ObjectNet allows users to decide how much time the server will take to detect when the client disconnects from the server. This option can be useful to not disconnect the client when the connection is lost and reconnected in a short period of time due to some network problem. ObjectNet when using OnlineObjectTranport implements a keep-alive message to detect if the client is still connected to the server, when this message does not arrive after this period of time the system assumes that this client was disconnected. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem61.png&width=768&dpr=4&quality=100&sign=9b60a5ae&sv=2) To update this value you need to slide the horizontal according to the desired value, and each unity represents 1 second on time. [PreviousServer Mode](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/server-mode) [NextServer Connection](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/connections/server-connection) --- # Network Prefabs | ObjectNet Network Prefabs is a structure used to keep objects synchronized over a network. * * * Question: But, what is "Network Prefab" by definition? Answer: Network Prefab is any prefab object that the system will detect its creation or destroy and will keep synchronized on all instances of the same game. * * * The following drawing illustrates how ObjectNet works to keep Network Prefabs synchronized over the network. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fcontent.gitbook.com%2Fcontent%2FNG75ky1pR1kRokWLRnzy%2Fblobs%2FIiKP9HIcuvnugzhmyETv%2FNewItem28.png&width=768&dpr=4&quality=100&sign=7a8452a&sv=2) Network Prefabs allow you to keep game objects synchronized without the need to change any script or code from your game. This simple but powerful mechanism allows you to port any game with no or fewer changes into the current source code. [PreviousNetwork Events](https://onlineobject.gitbook.io/objectnet/general/fundamentals/network-events) [NextObject Updates](https://onlineobject.gitbook.io/objectnet/general/fundamentals/object-updates) --- # Client Connection | ObjectNet ObjectNet provides a flexible interface to handle servers, this can be configured on the "Connection Parameters" section. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem69.png&width=768&dpr=4&quality=100&sign=77cfdc6&sv=2) Transport port[](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/connections/client-connection#transport-port) You can define the port used on your game by setting the port on the "Transport Port" field. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem70.png&width=768&dpr=4&quality=100&sign=22416148&sv=2) Once defined, both transport systems ( OnlineObjectTranport and UnityTransport ) will use this port as a reliable and unreliable delivery method. Nonetheless, ObjectNet is flexible and in case your custom transport system needs different ports for reliable and unreliable messages you can define this by setting TransportPortType provided by ITransport interface ( see API reference for more information's ). * * * Single Server[](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/connections/client-connection#single-server) Single Server mode tells to client to connect to a specific IP. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem71.png&width=768&dpr=4&quality=100&sign=3cd8820d&sv=2) This option uses a unique and unchangeable server address and uses hard code address information as the server target. This option should only be used if you have some type of internal load balance to redirect communication into some Kubernetes or other technology. Multiple Servers[](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/connections/client-connection#multiple-servers) Multiple Servers mode provide a list of possible server to the client connect. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem72.png&width=768&dpr=4&quality=100&sign=c654379a&sv=2) In this scenario, the system will try to connect with the server host with the lowest ping possible. This ensures that players will also be connected to the best server possible. Dynamic Server(s)[](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/connections/client-connection#dynamic-server-s) Dynamic Server(s) mode provides a smart way to decide which server players will try to connect. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem73.png&width=768&dpr=4&quality=100&sign=66bb3f27&sv=2) In this scenario, developers can create any logic to decide which server the client will try to connect to. To create a Dynamic Server provider you need to create a script to provide server information, this script shall implement the interface IInformationProvider to return the possible list of servers to try to connect ( see [Providers Scripts](https://onlineobject.gitbook.io/objectnet/general/fundamentals/providers-scripts) ). You can also check the example script ServerAddressProvider on examples folder. This script has a full implementation of how to provide server addresses to dynamic servers. [PreviousServer Connection](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/connections/server-connection) [NextEnable Login](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/enable-login) --- # Network Manager | ObjectNet NetworkManager is the main controller of ObjectNet and he is responsible to control and manage the main aspects of the multiplayer system. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fcontent.gitbook.com%2Fcontent%2FNG75ky1pR1kRokWLRnzy%2Fblobs%2FtXFTfsZZwCvBPS6pwr8O%2FNewItem12.png&width=768&dpr=4&quality=100&sign=a06333f5&sv=2) NetworkManager is the final layer of ObjectNet core system, and he is responsible for handling all elements of your multiplayer game. * On NetworkManager you can define or configure all aspects of your multiplayer. On the NetworkManager editor, you can configure the following properties. * Network Database * Network Transport * Server Mode * Connections * Connection Parameters * Send Configurations * Delivery Mode * Network Prefabs * Enable Login * Enable Encryption * Network Clock * Latency Tolerance * Movement Prediction * Remote Controls * Measure Latency * Player Prefab [PreviousNetwork Components](https://onlineobject.gitbook.io/objectnet/general/network-components) [NextNetwork DataBase](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/network-database) --- # Network DataBase | ObjectNet NetworkDatabase is the structure responsible for storing all NetworkPrefabs and NetworkEvents databases into a unique internal database. Each NetworkManager and NetworkEventsManager can target just one database per game. The selected database appears on the top of NetworkManager object. To modify the current Database you shall click on the eye icon close to the "Click to modify" message. A new "Network Database" window shall appear. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fcontent.gitbook.com%2Fcontent%2FNG75ky1pR1kRokWLRnzy%2Fblobs%2FPVEWfUtdNTYlIcGGEgvK%2FScreenshot%25202025-04-16%2520214153.png&width=768&dpr=4&quality=100&sign=9b0c977e&sv=2) Click on the eye icon ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fcontent.gitbook.com%2Fcontent%2FNG75ky1pR1kRokWLRnzy%2Fblobs%2FXyIp84scoTMPckiDJLmC%2FNewItem14.png&width=768&dpr=4&quality=100&sign=cf4dd0ca&sv=2) Network DataBase Window Creating DataBase[](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/network-database#creating-database) 1. To create a new Database you shall fill in the Database Name field and press "Create" 2. A new database shall appear on the last record on the listed database. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fcontent.gitbook.com%2Fcontent%2FNG75ky1pR1kRokWLRnzy%2Fblobs%2FcWShp8gQ8GLJ92UoqgoQ%2FScreenshot%25202025-04-16%2520174436.png&width=768&dpr=4&quality=100&sign=811f99c3&sv=2) Deleting DataBase[](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/network-database#deleting-database) 1. Locate the database that you wish to delete 2. Click on the remove button on the left side of the database name ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fcontent.gitbook.com%2Fcontent%2FNG75ky1pR1kRokWLRnzy%2Fblobs%2FV9LATOuuvwojp8SVSwmp%2FNewItem18.png&width=768&dpr=4&quality=100&sign=cd373108&sv=2) Changing DataBase[](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/network-database#changing-database) 1. Locate the database that you wish to select 2. Click on the select button on the right side of the database name 3. The selected database shall appear in red color ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fcontent.gitbook.com%2Fcontent%2FNG75ky1pR1kRokWLRnzy%2Fblobs%2FKXwcwORUQrkMA74AJ1e5%2FScreenshot%25202025-04-16%2520174645.png&width=768&dpr=4&quality=100&sign=a950ca73&sv=2) [PreviousNetwork Manager](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager) [NextNetwork Transport](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/network-transport) --- # Movement Prediction | ObjectNet ObjectNet provides an embedded Movement Prediction system to allow users of competitive games to reduce or mitigate latency problems. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem87.png&width=768&dpr=4&quality=100&sign=c1563766&sv=2) Movement Prediction has a few options to adjust a fine-tuning. ### [](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/movement-prediction#prediction-buffer-size) **Prediction Buffer Size:** This option creates a buffer where each past position is stored to be used as a database of predicted positions, you can adjust according to your needs. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem88.png&width=768&dpr=4&quality=100&sign=ef7847fd&sv=2) ### [](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/movement-prediction#prediction-mode) **Prediction Mode:** Prediction mode tells the ObjectNet how the system will check the parameters ( such as distance, angular velocity, linear velocity, etc.. ) needed to predict movement and the values can be : 1. **Automatic** : The system will automatically select the best approach 2. **By Transform :** The system will use transform to calculate needed values, this can be useful if your objects don't have a rigid body. 3. **By Physics:** The system will use physics objects ( such as Rigid Body ) to calculate needed values. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem89.png&width=768&dpr=4&quality=100&sign=2738d678&sv=2) Latency Factor[](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/movement-prediction#latency-factor) This topic explains how latency affects your game and how the Latency factor parameter can be used to mitigate this problem. Latency is a challenge that has been a pursuit in multiplayer games since its first appearance, the latency in short, makes thing appear different from different players depending on how much time event and information arrives on their local instance. The following drawing illustrates a latency problem in a racing game : ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem90.png&width=768&dpr=4&quality=100&sign=9460452&sv=2) In the example above the vehicle on the client is always one step behind the vehicle on the server side, this can generate a lot of conditions that may break some game logic, In the ideal universe, both vehicles should keep synchronized. Latency is a problem that you can mitigate or leave with but is impossible to solve completely. The Latency Factor tells the engine how in front object shall appear depending on player latency. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem94.png&width=768&dpr=4&quality=100&sign=18aae816&sv=2) The above example illustrates how the Latency Factor works according to latency to keep the player close to the real position event when latency delay packet to be delivered to the client, how much more latency, more in front vehicle shall appear. Speed Factor[](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/movement-prediction#speed-factor) This topic explains how objects' speed affects how prediction shall calculate real object position and how the Speed Factor parameter can be used to mitigate this problem. When an object is moving, the amount of traveled distance can vary according to its speed, this can be expressed by the physics formula \[ DISTANCE = SPEED x TIME \]. This means that much faster the object is moving, the more in front it should appear when latency increases. Suppose that a vehicle is moving at 10 Km/h and you do not consider its speed during prediction, the result could be that you put the vehicle in front where the real appears on the server. The following drawing(s) illustrates a latency problem in a racing game : ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem96.png&width=768&dpr=4&quality=100&sign=88f5abe4&sv=2) Now let's suppose that the same vehicle starts to move at 80km/h and you still do not consider his speed during prediction, the result could be that you put the vehicle in behind where the real appears on the server. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem97.png&width=768&dpr=4&quality=100&sign=7bf2a4a9&sv=2) In both examples, the vehicle isn't synchronized with regard to his real position on the server due to the variation in vehicle speed. Speed Factors mitigate this problem including object speed on prediction calculation. This means how much faster an object is moving, how much in front they shall appear when latency increases. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem99.png&width=768&dpr=4&quality=100&sign=e4ac1bc7&sv=2) The above example illustrates how the Speed Factor works to mitigate this problem by adding object speed during calculations. Custom Prediction[](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/movement-prediction#custom-prediction) Embedded Movement Prediction provided by ObjectNet should work on all cases, nonetheless, ObjectNet provides an API to allow developers to create their own movement prediction and override the default prediction. You can override the default prediction system by checking "Use custom prediction" option. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem100.png&width=768&dpr=4&quality=100&sign=51b023a&sv=2) To create your own prediction system you need to create a provider script that implements the interface IPrediction ( see [Providers Scripts](https://onlineobject.gitbook.io/objectnet/general/fundamentals/providers-scripts) ). You can also check the example script PredictionProvider in the examples folder. This script has a skeleton implementation of a custom prediction system. [PreviousEnable Login](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/enable-login) [NextRemote Controls](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/remote-controls) --- # Remote Controls | ObjectNet [](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/remote-controls#general) General: ------------------------------------------------------------------------------------------------------------------------------ Depending on the approach you decide to take on your game, you can send object data from clients but send client input controls only. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem101.png&width=768&dpr=4&quality=100&sign=bf85cfc7&sv=2) Question : But was it considered a Control? Answer : Control is anything that the system can use to interact with the game, such as Keyboard, GamePad, Joystick, etc... Remote controls can be synchronized in two ways, by using NetworkManager or in case of script inherits from NetworkBehaviour by code. [](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/remote-controls#synchronized-using-networkmanager) Synchronized using NetworkManager --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- When Remote Controls is enabled, a system with put all objects as passive ( event local player ) and your player will move only based on server position and actions. This can be very useful if you are trying to isolate your game from any cheating or hacking, since the server will only process player inputs, instead of sending and receiving his position and events to the server. To use Remote Controls you will need to take the following steps : 1. Create an script o implement how you with catch Inputs This script must implement IInputProvider interface. Each method of this script must return the state of input witch he is mapping, the following code is an example of how to implement those methods. Copy public bool IsJumpPressed() { return Input.GetKey(KeyCode.Space); } public bool IsFrontPressed() { return Input.GetKey(KeyCode.UpArrow); } public bool IsBackPressed() { return Input.GetKey(KeyCode.DownArrow); } public bool IsLeftPressed() { return Input.GetKey(KeyCode.LeftArrow); } public bool IsRightPressed() { return Input.GetKey(KeyCode.RightArrow); } public Vector2 GetMovement() { return new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical")); } Each method maps one input, and the possible return values shall be only bool, float and Vector2. You can also check the example script Input Provider in the examples folder. This script is a full implementation of the Input Provider. 1. Assign prefab and component where script provider is attached ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem102.png&width=300&dpr=4&quality=100&sign=49227868&sv=2) 3\. Register all possible controls on NetworkManager ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem103.png&width=768&dpr=4&quality=100&sign=ea1aa0ad&sv=2) Each method must have a unique alias to be identified by the system and sent through the network. 1. Get an instance of ObjectNet class "NetworkObject" from current NetworkPrefab. Copy this.network = this.GetComponent(); 1. Instead of using the direct Unity Input Methods ( or any other API ) get input status, you need to use ObjectNet input methods. Copy this.network.GetInput("MoveLeft"); this.network.GetInput("MoveRight"); this.network.GetInput("Jump"); * * * [](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/remote-controls#synchronized-using-by-code-networkmanager) Synchronized using by code NetworkManager ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Remote control can also be synchronized by code, this can be useful if you need to do some rebinding or procedural generation. The following piece of code shows how to synchronize Network Inputs by code. Copy public void Awake() { // To map controls this.RegisterInput("jump").OnEvaluate(() => { return Input.GetKeyDown("space"); }); this.RegisterInput("lados").OnEvaluate(() => { return Input.GetAxis("horizontal"); }); } Each control needs to be mapped with the method which will return his current status. [PreviousMovement Prediction](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/movement-prediction) [NextPlayer Prefab](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/player-prefab) --- # Other Settings | ObjectNet Send configurations[](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/other-settings#send-configurations) This option allows to configuration of how many updated systems will try to send peer seconds. This option applies only to internal object update messages controlled by the system ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fcontent.gitbook.com%2Fcontent%2FNG75ky1pR1kRokWLRnzy%2Fblobs%2F8dRGzeOxNx78yDmVZrRq%2Fimage.png&width=768&dpr=4&quality=100&sign=bcb99985&sv=2) You can control the number of update object messages peer seconds ObjectNet will send to keep the client synchronized, depending on how your game was designed this number can be greater or smaller, games like FPS or Racing may require a large number of messages to provide accuracy, although, card games, point and click and another type may require a just a few messages, this option allows a fine twin on this aspect of your game. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fcontent.gitbook.com%2Fcontent%2FNG75ky1pR1kRokWLRnzy%2Fblobs%2FLgF1WnkUgVevC7vY3uhf%2FScreenshot%25202025-04-17%2520002535.png&width=768&dpr=4&quality=100&sign=f1b7dd6b&sv=2) ObjectNet has a smart system to detect when there are no changes to decrease the send rate to Minimum update frequency saveing bandwidth Delivery Mode[](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/other-settings#delivery-mode) This option allows one to decide how ObjectNet will deliver object update messages. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem75.png&width=300&dpr=4&quality=100&sign=cdbd59d1&sv=2) Object Update messages can be delivered in two ways Reliable and Unreliable. This option when combined with update frequency may provide a better and more reliable experience to the player at the same time that they reduce network costs. Enable Encryption[](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/other-settings#enable-encryption) ObjectNet provides an optional feature to allow the developer to encrypt data information. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem84.png&width=768&dpr=4&quality=100&sign=2ea52b79&sv=2) Before sending data and after receiving data, ObjectNet will try to Encrypt or Decrypt data before sending by the selected transport system. Do you need to implement a script inherited from IInformationProvider ( see [Providers Scripts](https://onlineobject.net/objectnet/docs/manual/ProvidersScripts.html) ). This script shall implement two methods, one to Encrypt and another to Decrypt. You can also check the example script EncryptionProvider on examples folder. This script has a full implementation of how to encrypt and Decrypt data using provided C# classes, nonetheless, you can also implement your encryption method. You can also check a full example scene "19 - Encryption" which has the encryption implemented. Network Clock[](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/other-settings#network-clock) ObjectNet provides one implementation of a clock designed to be more accurate than the internal unity clock where the target is multiplayer operations. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fcontent.gitbook.com%2Fcontent%2FNG75ky1pR1kRokWLRnzy%2Fblobs%2FwRzSGQ74KuhcConRYVwA%2FNewItem85.png&width=768&dpr=4&quality=100&sign=d155ccc6&sv=2) This internal clock has the same functionalities as the Unity Time class, we recommend using ObjectNet time wrapper which will decide which clock they will use. We strongly recommend using those functions if you are starting your development : Copy NetworkClock.deltaTime NetworkClock.fixedDeltaTime NetworkClock.time NetworkClock.deltaFrames NetworkClock.tick If Network Clock is enabled, ObjectNet will use its internal clock, nonetheless, if Network Clock is not enabled ObjectNet will use the Unity default clock. To see each function in detail check ObjectNet API documentation. Latency Tolerance[](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/other-settings#latency-tolerance) ObjectNet provides an embedded [Movement Prediction](https://onlineobject.net/objectnet/docs/manual/MovementPrediction.html) system to predict object movement and mitigate latency. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem86.png&width=768&dpr=4&quality=100&sign=25fc7713&sv=2) Movement Prediction uses those values to calculate the predicted position of an object over the network. In this configuration you have two options : 1. Good Latency Good latency is the latency between 0ms and the selected value, this latency is considered a good value for players playing your game. 1. Acceptable Latency Acceptable latency starts on the end of good latency up to the selected value, and movement prediction will predict in a different way if latency is on the acceptable bounds. If values exceed the acceptable value the movement prediction will use his extrapolated prediction without affecting game-play. Movement Interpolation[](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/other-settings#movement-interpolation) Always when remote object position was received, the new received position became the current object position this may cause some teleportation or jittering on objects. ObjectNet provide the facility to smoothly move objects during network movement to avoid jittering or flicker on game objects. To enable internal latency measure you need to enable "Movement Interpolation" on NetworkPrefab. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem223.png&width=768&dpr=4&quality=100&sign=92eb5fa8&sv=2) Note: ObjectNet will always work to mitigate and reduce flicker and jittering, nonetheless, depending of the latency or packets lost you may experiment certain issues. Measure Latency[](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/other-settings#measure-latency) ObjectNet uses a lot of measurement systems to keep peers synchronized, some of those are provided by Operational System or Unity, nonetheless, ObjectNet has a custom measurement system to get more accurate information. One of those measure is the latency. The latency is the time that a package takes for one peer to arrive at the server. To enable internal latency measure you need to enable "Measure Latency" on NetworkPrefab. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem104.png&width=768&dpr=4&quality=100&sign=352163fe&sv=2) Now you can get the Ping through code using Copy int averagePing = NetworkManager.Instance().GetPingAverage(); [PreviousPlayer Prefab](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/player-prefab) [NextNetwork Prefabs](https://onlineobject.gitbook.io/objectnet/general/network-components/network-prefabs) --- # Server Connection | ObjectNet ObjectNet provides a flexible interface to handle servers, this can be configured on the "Connection Parameters" section. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem205.png&width=768&dpr=4&quality=100&sign=53970474&sv=2) Transport port[](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/connections/server-connection#transport-port) You can define the port used on your game by setting the port on the "Transport Port" field. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem70.png&width=768&dpr=4&quality=100&sign=22416148&sv=2) Once defined, both transport systems ( OnlineObjectTranport and UnityTransport ) will use this port as a reliable and unreliable delivery method. Nonetheless, ObjectNet is flexible and in case your custom transport system needs different ports for reliable and unreliable messages you can define this by setting TransportPortType provided by ITransport interface ( see API reference for more information's ). Server mode provides some options when the server starts to listen for incoming connections, in general, no option is better than the other, nonetheless, some options can fit better depending on the scenario: Default Address[](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/connections/server-connection#default-address) Default Address left to the operation system the responsibility to choose the correct network interface to listen. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem206.png&width=768&dpr=4&quality=100&sign=c5669193&sv=2) Note: This is the best option if you don't know which option to choose. Use Fixed Address[](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/connections/server-connection#use-fixed-address) Use Fixed Address will only listen coming packet arrived on the network interface connected to this address ip. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem207.png&width=768&dpr=4&quality=100&sign=60c051e6&sv=2) This can be used when you have many network interfaces and you need to define the correct one to use. Use Public Address[](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/connections/server-connection#use-public-address) The Public Server will use the address visible to the internet, normally the IP Address on your router. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem208.png&width=768&dpr=4&quality=100&sign=8ee2627d&sv=2) This option only makes sense if you have NAT Traversal enabled or manually created the route on your router. Note: This does not ensure that connections outside of your LAN can connect with your server, this option only makes sense if your computer has a public IP. Use Internal Address[](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/connections/server-connection#use-internal-address) Using an Internal Address will force you to use the network address connected with the router, this will make use of the IP Address visible for your own LAN Network. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem209.png&width=768&dpr=4&quality=100&sign=c6a2f0f8&sv=2) This is also the best option to use if you use NAT Traversal because the router will redirect all connections from outside to this network interface. [PreviousConnections](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/connections) [NextClient Connection](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/connections/client-connection) --- # Enable Login | ObjectNet ObjectNet provides a full login feature to protect your game ensuring that players on the game need to be logged. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem78.png&width=768&dpr=4&quality=100&sign=1f263120&sv=2) Login provided work in two steps: Login Provider[](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/enable-login#login-provider) Login Provider is how ObjectNet collects a login information to perform login authentication operation. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem77.png&width=768&dpr=4&quality=100&sign=dc22a96b&sv=2) To collect login information you need to create a login provider script that implements the interface IInformationProvider to interact with your UI ( see [Providers Scripts](https://onlineobject.gitbook.io/objectnet/general/fundamentals/providers-scripts) ). This script shall implement two methods, one to collect information and another to identify each parameter type ( Boolean, String, Integer, etc ... ).. You can also check the example script LoginInformationProvider in the examples folder. This script has a full implementation of how to provide login information. You can also check a full example scene "02 - Login". In this example, you have a full example of how to implement your custom login including a UI. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem79.png&width=768&dpr=4&quality=100&sign=16c23485&sv=2) You can use the following users and passwords to test it. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem80.png&width=768&dpr=4&quality=100&sign=5cff835&sv=2) Enable Validation[](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/enable-login#enable-validation) Login Validation is how ObjectNet checks if authentication data is valid or not. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem81.png&width=768&dpr=4&quality=100&sign=8f34e910&sv=2) After data is collected, ObjectNet needs to check if this information is valid. To do this ObjectNet uses another script that implements the interface IInformationProvider to validate the information ( see [Providers Scripts](https://onlineobject.gitbook.io/objectnet/general/fundamentals/providers-scripts) ). This script shall implement a method to check this user against any authentication service such as Database, WebService, PlayFab, Steam, or any other. You can also check the example script LoginValidationProvider in the examples folder. This script has a full implementation of how to validate login information. You can also check the full example scene "02 - Login". In this example, you have a full example of how to implement your custom login including a UI. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem79.png&width=768&dpr=4&quality=100&sign=16c23485&sv=2) You can use the following users and passwords to test it. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem83.png&width=300&dpr=4&quality=100&sign=e3409462&sv=2) [PreviousClient Connection](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/connections/client-connection) [NextMovement Prediction](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/movement-prediction) --- # Player Prefab | ObjectNet In a MultiPlayer game, each player shall have his player avatar to play, ObjectNet provides the facility to control this object, and the left object manages his creation and destruction. This functionality is called Player Prefab. Player Prefab is an internal process to control a player's avatar life-cycle. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fcontent.gitbook.com%2Fcontent%2FNG75ky1pR1kRokWLRnzy%2Fblobs%2FM5yVMVZ3B560ezZbh8zb%2Fimage.png&width=768&dpr=4&quality=100&sign=44691bef&sv=2) Use Single prefab[](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/player-prefab#use-single-prefab) The Single Prefab option fixed the spawned prefab for all players who enter the game. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem106.png&width=768&dpr=4&quality=100&sign=ad3504cc&sv=2) In the image above, every time a player enters a game the prefab "Player Armature" will be spawned and associated with this player. Use Dynamic Spawner[](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/player-prefab#use-dynamic-spawner) The Dynamic Spawner option allows to creation of a custom logic to decide which prefab will be spawned for each player. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem116.png&width=768&dpr=4&quality=100&sign=5204165b&sv=2) This option allows to spawn prefab to each player individually and implement some type of skin feature. Internal Network ID[](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/player-prefab#internal-network-id) On ObjectNet each network object must have a unique ID, this ID is the way objects are identified over the network.. This ID could be controlled internally by the system, the option "Internal Network ID" generates a sequential unique ID for each player created. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem113.png&width=768&dpr=4&quality=100&sign=79aa824a&sv=2) For a casual game where the player is not identified this is a safe time option, since you don't need to be worried about player identification. Custom Network ID[](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/player-prefab#custom-network-id) ObjectNet provides a facility to identify a spawned player with a unique state-full ID. This is pretty useful if you wish to reuse a player session in case of any disconnection. Associated a unique ID to the player allows bringing the player back when a player is reconnected at the same match. This option can be enabled by checking the "Custom Network ID" option. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem115.png&width=768&dpr=4&quality=100&sign=e53f24dc&sv=2) This ID shall originate from a state full source such as a Database, PlayFab, Steam, or any other. The Custom Network ID option requires a logic to return the Network ID to associate with the player. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem118.png&width=768&dpr=4&quality=100&sign=e0a9ac35&sv=2) In the image above, the "NetworkIdProvider" is the object with a component NetworkIdProvider which has a method called "GetNetworkId". To create a NetworkIdProvider provider you will need to create a script to provide a custom ID, this script shall implement the interface IInformationProvider to return the ID to be associated with the player prefab to be spawned ( see [Providers Scripts](https://onlineobject.gitbook.io/objectnet/general/fundamentals/providers-scripts) ). You can also check the example script NetworkIdProvider in the examples folder. This script has a full implementation of how to provide custom IDs. Position to Spawn[](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/player-prefab#position-to-spawn) When some player is spawned, the system shall decide the position where this player will be spawned. ObjectNet provides a facility to decide where the system will spawn players. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem120.png&width=768&dpr=4&quality=100&sign=494216ec&sv=2) ### [](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/player-prefab#fixed-position) Fixed Position: Fixed Position do what his name suggests, spawn all players on a specific position.. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem122.png&width=768&dpr=4&quality=100&sign=14b7cc9e&sv=2) On the field "Position to Spawn" a transform must be provided, all players will be spawned on this exact position. ### [](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/player-prefab#multiple-positions) Multiple Positions Multiple Positions allow to spawn players into different positions according to a provided list of possible positions. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem123.png&width=768&dpr=4&quality=100&sign=126221ab&sv=2) The system will perform a random rounding robin algorithm to select the next position to spawn, which means that the next player will not be spawned at the same position as the previous one. When all positions are used, the system will restart his list and start to spawn from scratch. This ensures that no one player will be close to another and all possible position has players spawned. ### [](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/player-prefab#dynamic-position) Dynamic Position Dynamic Position allows to spawn players into positions according to some custom logic. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem124.png&width=768&dpr=4&quality=100&sign=60585388&sv=2) In the image above, the "PositionPrefabProvider" is the object with a component PositionProvider which has a method called "GetSpawnPosition". To create a Dynamic Position provider you will need to create a script to provide the position to spawn the player, this script shall implement the interface IInformationProvider to return the position to use when the prefab was spawned ( see [Providers Scripts](https://onlineobject.gitbook.io/objectnet/general/fundamentals/providers-scripts) ). You can also check the example script PositionProvider in the examples folder. This script has a full implementation of how to provide positions. Control player cameras[](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/player-prefab#control-player-cameras) The option Control Player Cameras grand to ObjectNet the responsibility to control all cameras attached to the players. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem125.png&width=768&dpr=4&quality=100&sign=6a2ceb4d&sv=2) ObjectNet will ensure that only one camera is working on the system, when another player is spawned, ObjectNet will try to find the camera associated with the local player owner of the current instance of the game, and make this camera the only camera working on the scene. This option is pretty useful to avoid mistakes when handling multiple cameras inside each player's prefab. Detach camera from player[](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/player-prefab#detach-camera-from-player) The option Detach camera from the player will remove the camera from the spawned player and put it at the root of the scene hierarchy. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem126.png&width=768&dpr=4&quality=100&sign=938a2bda&sv=2) When the player camera is placed inside NetworkPrefab for convenience reasons but after spawned the same camera has some damping algorithm who not work properly due to the fact of being inside Player. This option is useful because after spawned, the camera will be removed from the player object and placed at the top of the scene hierarchy. Remove player on disconnect[](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/player-prefab#remove-player-on-disconnect) ObjectNet controls all object's life cycles, this means that ObjectNet can detect when an object needs to be destroyed. The option "Remove player on disconnect" will destroy the player's game object when the player disconnects from the server. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem127.png&width=768&dpr=4&quality=100&sign=1cb6f267&sv=2) ObjectNet allows to destroy the player after a certain amount of time if disconnection is detected, the option "Remove disconnected after time" enables this feature. If this option is not flagged, an extra option shall appear to allow to destruction player after a certain amount of time. This option must be used in case a game allows them to play back on the game after disconnection, when combined with "Custom Network ID" the disconnected player may back to the game and restore the status that they had before disconnected. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem128.png&width=768&dpr=4&quality=100&sign=6d40bb04&sv=2) Note: If both options "Remove player on disconnect" and "Remove disconnected after time" were not flagged, the player object will keep on the scene while the match is not finished or the game is running. [PreviousRemote Controls](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/remote-controls) [NextOther Settings](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/other-settings) --- # Step 3 - Network Prefabs | ObjectNet ObjectNet need to know what are the prefabs that he will handle over the network. To know more about network prefabs read [Network Prefabs](https://onlineobject.gitbook.io/objectnet/general/network-components/network-prefabs) section. Click on Network Prefabs button. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem235.png&width=768&dpr=4&quality=100&sign=b092aa45&sv=2) A new window shall appear with you current Network Prefabs. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem236.png&width=768&dpr=4&quality=100&sign=9326672&sv=2) Now you need to select your player prefab, if you don't have one you can use one of the prefabs provided on the ObjectNet example. To check how to import examples read the [Example Scenes](https://onlineobject.gitbook.io/objectnet/general/example-scenes) section. In our step-by-step, we going to use the "Basic Player" prefab. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem237.png&width=768&dpr=4&quality=100&sign=841f553f&sv=2) Drag "Basic Player" prefab to "Prefab to register" field and press "Register Prefab". ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem238.png&width=768&dpr=4&quality=100&sign=dd27d6c&sv=2) Prefab shall appear as registered on Network Prefabs list. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem239.png&width=768&dpr=4&quality=100&sign=f9623991&sv=2) [PreviousStep 2 - Defining a Database](https://onlineobject.gitbook.io/objectnet/getting-started/quickstart/step-2-defining-a-database) [NextStep 4 - Player Prefab](https://onlineobject.gitbook.io/objectnet/getting-started/quickstart/step-4-player-prefab) --- # Step 2 - Defining a Database | ObjectNet Network Manager has a lot of options, but we will keep on simple and configure only the parameter to start our multiplayer game. ObjectNet uses a database system to provide more than one game mode on the same game, to know more about the database read the [Network DataBase](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/network-database) section. Click on eye icon to setup a database. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem231.png&width=768&dpr=4&quality=100&sign=95534e49&sv=2) A list of existent databases will appear. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem232.png&width=768&dpr=4&quality=100&sign=712ad236&sv=2) Now you need to create a new database to your example, fill the database name with you database and press Create. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem233.png&width=768&dpr=4&quality=100&sign=9e1b6ba3&sv=2) A new database shall appear at bottom of list, click "Select" to set this is the current database. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem234.png&width=768&dpr=4&quality=100&sign=c6386de0&sv=2) [PreviousStep 1 - Configuring Scene](https://onlineobject.gitbook.io/objectnet/getting-started/quickstart/step-1-configuring-scene) [NextStep 3 - Network Prefabs](https://onlineobject.gitbook.io/objectnet/getting-started/quickstart/step-3-network-prefabs) --- # Step 5 - Spawn Position | ObjectNet Now we need to define where your player will be spawned, we can do this by setting "Spawn Position" on NetworkManager. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem245.png&width=300&dpr=4&quality=100&sign=775366c8&sv=2) But first we going to put a terrain to step over. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem247.png&width=300&dpr=4&quality=100&sign=1b663d1a&sv=2) Now we have a terrain on our scene. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem248.png&width=300&dpr=4&quality=100&sign=ea582909&sv=2) Let's to add another GameObject to work as spawn point reference. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem250.png&width=300&dpr=4&quality=100&sign=bcc6c98e&sv=2) Name it as "SpawnPosition" but you can choose any name. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem251.png&width=300&dpr=4&quality=100&sign=4d525f9b&sv=2) Place it at center of terrain over the terrain ( not under ). ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem252.png&width=300&dpr=4&quality=100&sign=3b1e6a1c&sv=2) Now drag "SpawnPosition" object to "Position to Spawn" field. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem253.png&width=300&dpr=4&quality=100&sign=246df241&sv=2) Position to Spawn shall use the transform of "SpawnPosition" object. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem254.png&width=300&dpr=4&quality=100&sign=4698128a&sv=2) [PreviousStep 4 - Player Prefab](https://onlineobject.gitbook.io/objectnet/getting-started/quickstart/step-4-player-prefab) [NextStep 6 - Setup Server](https://onlineobject.gitbook.io/objectnet/getting-started/quickstart/step-6-setup-server) --- # Step 4 - Player Prefab | ObjectNet Network Prefabs shall list all your network prefabs, including : * NPC * Weapons * Artifacts * Other Players * Vehicles * And everything that shall be spawned on all clients Nonetheless, you still need to tell to ObjectNet what of those prefabs represents your player, now you going to define which prefab is the player of your game. There are a lot of options regard how to spawn your player, to know more about read the [Player Prefab](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/player-prefab) section. Find the "Player Prefab" option on NetworkManager and check it ( a bunch of options shall appear as below ). ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem243.png&width=768&dpr=4&quality=100&sign=b89cc0de&sv=2) Even having many options we will keep it simple and only draw the "BasicPlayer" prefab to the field. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem236.png&width=768&dpr=4&quality=100&sign=9326672&sv=2) You need to use the same prefab defined [Step 3 - Network Prefabs](https://onlineobject.gitbook.io/objectnet/getting-started/quickstart/step-3-network-prefabs) . ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem242.png&width=768&dpr=4&quality=100&sign=3134aeeb&sv=2) [PreviousStep 3 - Network Prefabs](https://onlineobject.gitbook.io/objectnet/getting-started/quickstart/step-3-network-prefabs) [NextStep 5 - Spawn Position](https://onlineobject.gitbook.io/objectnet/getting-started/quickstart/step-5-spawn-position) --- # Step 6 - Setup Server | ObjectNet First, we need to define the working mode, ObjectNet can work with many modes, but in this example, we going to set it up as "Embedded". ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem255.png&width=768&dpr=4&quality=100&sign=7289997&sv=2) Some games provide the option to the player to start as a Server or Client, ObjectNet also provides this facility, to know more read the [Server Mode](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/server-mode) section. ObjectNet also provides ready-to-use examples where you can interact with users to select this option in the game and check the examples scene section [Example Scenes](https://onlineobject.gitbook.io/objectnet/general/example-scenes) . For now, let's finish your configuration by following the [Step 7 - Compiling Server](https://onlineobject.gitbook.io/objectnet/getting-started/quickstart/step-7-compiling-server) . [PreviousStep 5 - Spawn Position](https://onlineobject.gitbook.io/objectnet/getting-started/quickstart/step-5-spawn-position) [NextStep 7 - Compiling Server](https://onlineobject.gitbook.io/objectnet/getting-started/quickstart/step-7-compiling-server) --- # Step 8 - Compiling Client's | ObjectNet Lets to compile our client build. Go back to the NetworkManager and check the "Client" option. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem262.png&width=768&dpr=4&quality=100&sign=d104aa29&sv=2) Let's keep everything as it and build our Client. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem257.png&width=300&dpr=4&quality=100&sign=b680fd3d&sv=2) Click on "Build". ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem258.png&width=300&dpr=4&quality=100&sign=781b6ca6&sv=2) Create a new folder called "ClientBuild" and build it. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem263.png&width=300&dpr=4&quality=100&sign=de07b164&sv=2) Wait build to be finished. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem261.png&width=300&dpr=4&quality=100&sign=6dbced96&sv=2) [PreviousStep 7 - Compiling Server](https://onlineobject.gitbook.io/objectnet/getting-started/quickstart/step-7-compiling-server) [NextStep 9 - Running](https://onlineobject.gitbook.io/objectnet/getting-started/quickstart/step-9-running) --- # Step 7 - Compiling Server | ObjectNet Lets to compile out server build. Check the following options. "Server" shall be selected to start this instance as Server. "Connect on Start" shall be selected to start server when game is launched. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem256.png&width=768&dpr=4&quality=100&sign=de886ab8&sv=2) For testing purposes is recommended to build "Windowed" mode and "Re-sizable Window" option. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem266.png&width=768&dpr=4&quality=100&sign=c87a6d25&sv=2) Now lets build our Server. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem257.png&width=300&dpr=4&quality=100&sign=b680fd3d&sv=2) Click on "Build". ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem258.png&width=300&dpr=4&quality=100&sign=781b6ca6&sv=2) Create a new folder called "ServerBuild" and build it. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem260.png&width=300&dpr=4&quality=100&sign=615e9f83&sv=2) Wait to build be finished. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem261.png&width=300&dpr=4&quality=100&sign=6dbced96&sv=2) [PreviousStep 6 - Setup Server](https://onlineobject.gitbook.io/objectnet/getting-started/quickstart/step-6-setup-server) [NextStep 8 - Compiling Client's](https://onlineobject.gitbook.io/objectnet/getting-started/quickstart/step-8-compiling-clients) --- # Fundamentals | ObjectNet [Network Events](https://onlineobject.gitbook.io/objectnet/general/fundamentals/network-events) [Network Prefabs](https://onlineobject.gitbook.io/objectnet/general/fundamentals/network-prefabs) [Object Updates](https://onlineobject.gitbook.io/objectnet/general/fundamentals/object-updates) [Delivery Mode](https://onlineobject.gitbook.io/objectnet/general/fundamentals/delivery-mode) [Network Transport](https://onlineobject.gitbook.io/objectnet/general/fundamentals/network-transport) [DataStream](https://onlineobject.gitbook.io/objectnet/general/fundamentals/datastream) [Providers Scripts](https://onlineobject.gitbook.io/objectnet/general/fundamentals/providers-scripts) [PreviousStep 10 - Next Steps](https://onlineobject.gitbook.io/objectnet/getting-started/quickstart/step-10-next-steps) [NextNetwork Events](https://onlineobject.gitbook.io/objectnet/general/fundamentals/network-events) --- # Step 9 - Running | ObjectNet Now you should have two folders. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem264.png&width=768&dpr=4&quality=100&sign=a201ee1f&sv=2) Open "ServerBuild" and run the game. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem269.png&width=300&dpr=4&quality=100&sign=af59b57e&sv=2) The game shall start and the player spawned ( this player is the player obejct where game is running ). Open "Client Build" and run the game. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem270.png&width=300&dpr=4&quality=100&sign=1eaa8f70&sv=2) Your player shall be spawned and the previous player ( on the server ) will appear on your instance. All players shall appear in both instances and all movement will be reflected in both instances ( you can move by using W-A-S-D keys ). ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem272.png&width=768&dpr=4&quality=100&sign=855bfc2&sv=2) Now you also can run many instances as you wish. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem273.png&width=768&dpr=4&quality=100&sign=a433354f&sv=2) [PreviousStep 8 - Compiling Client's](https://onlineobject.gitbook.io/objectnet/getting-started/quickstart/step-8-compiling-clients) [NextStep 10 - Next Steps](https://onlineobject.gitbook.io/objectnet/getting-started/quickstart/step-10-next-steps) --- # Step 10 - Next Steps | ObjectNet Now you know the basic of basics to start, we strongly recommend checking this document and all topics to know how to extract all the power that ObjectNet can provide to you. We also recommend checking each example on examples scenes, they can bring a clear view of how to work with ObjectNet. [PreviousStep 9 - Running](https://onlineobject.gitbook.io/objectnet/getting-started/quickstart/step-9-running) [NextFundamentals](https://onlineobject.gitbook.io/objectnet/general/fundamentals) --- # Network Prefabs | ObjectNet Network Prefabs is one fundamental aspect of ObjectNet. ObjectNet controls all Network Object life-cycle internally, this means that ObjectNet catches and monitors all object creation and destruction. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fcontent.gitbook.com%2Fcontent%2FNG75ky1pR1kRokWLRnzy%2Fblobs%2FDrbOA7sJauipfrClom6s%2FNewItem129.png&width=768&dpr=4&quality=100&sign=1a078009&sv=2) When clicking on "Network Prefab" button a new window shall appear. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fcontent.gitbook.com%2Fcontent%2FNG75ky1pR1kRokWLRnzy%2Fblobs%2FdHEgyyQdm2q5Dv0q1vmh%2FScreenshot%25202025-04-16%2520162746.png&width=768&dpr=4&quality=100&sign=6de95656&sv=2) [PreviousOther Settings](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/other-settings) [NextRegistering Prefab](https://onlineobject.gitbook.io/objectnet/general/network-components/network-prefabs/registering-prefab) --- # Registering Prefab | ObjectNet Network Prefabs works like a prefabs database, this means that all prefabs must be registered on this database. 1. Drag the prefab to the "Prefab to register" field and click on "Register Prefab". ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem133.png&width=768&dpr=4&quality=100&sign=ef713c30&sv=2) 1. The prefab shall be added to the list of registered prefabs ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem134.png&width=768&dpr=4&quality=100&sign=6d4c75b3&sv=2) All objects that need to be spawned to all players must be included on this list, this will allow ObjectNet to automatically detect when the object was spawned and destroy and create it on all instances of the game.n Network Prefabs has a bunch of options to keep objects updated and synchronized over the network. Note : Any player prefab must be registered as NetworkPrefab, otherwise prefab will not be spawned on the client instance. [PreviousNetwork Prefabs](https://onlineobject.gitbook.io/objectnet/general/network-components/network-prefabs) [NextSynchronization Options](https://onlineobject.gitbook.io/objectnet/general/network-components/network-prefabs/synchronization-options) --- # Synchronization Options | ObjectNet Network Prefab is a component handled by ObjectNet and its main purpose is to keep objects up to date regard to all network peers. ObjectNet provides the facility to automatically update some object aspects and behaviors by checking each option on each prefab. ### [](https://onlineobject.gitbook.io/objectnet/general/network-components/network-prefabs/synchronization-options#auto-sync) **Auto Sync:** This option will keep the Position, Rotation, and Scale of the object synchronized on all network peers ### [](https://onlineobject.gitbook.io/objectnet/general/network-components/network-prefabs/synchronization-options#sync-particles) **Sync Particles:** This option will keep the particle system synchronized on all peers, when the particle is started or stopped on an active object, all network peers will be notified to do the same. The RateOverTime and RateOverDistance will also be synchronized. ### [](https://onlineobject.gitbook.io/objectnet/general/network-components/network-prefabs/synchronization-options#sync-animation) **Sync Animation** ObjectNet also synchronizes animations automatically on network prefabs. Animation can be synchronized using 3 different modes: * **Using Controller** : This will try to use an animation controller to keep animations synchronized. * **Using Parameters** : This will try to use animation parameters to keep animations synchronized ( recommended ). * **Manually** : On this option, animations must be played and stopped manually by code using the NetworkAnimationController animation API ( see [Manual Animations](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/manual-animations) ). ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fcontent.gitbook.com%2Fcontent%2FNG75ky1pR1kRokWLRnzy%2Fblobs%2F33iN7iQn6cvw9bJ6B03r%2FNewItem135.png&width=768&dpr=4&quality=100&sign=2e0b24cf&sv=2) [PreviousRegistering Prefab](https://onlineobject.gitbook.io/objectnet/general/network-components/network-prefabs/registering-prefab) [NextPrefab Scripts](https://onlineobject.gitbook.io/objectnet/general/network-components/network-prefabs/prefab-scripts) --- # Prefab Scripts | ObjectNet Network Prefabs like any game object may have scripts and components to control their behavior. ObjectNet automatically disables all scripts when the game object is in passive mode since this object will be controlled remotely by the server, nonetheless, in certain circumstances some scripts shall be activated. Scripts can be enabled/disabled by clicking on the script's icon. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem136.png&width=300&dpr=4&quality=100&sign=5442b019&sv=2) A list of all scripts on each game object (including children) will appear, and you can enable/disable any script. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem137.png&width=768&dpr=4&quality=100&sign=a209b914&sv=2) By flagging the check box you can enable the script to run on passive instances. In case any script needs to be executed before being disabled ( if some data was collected in OnAwake on OnStart methods ) you shall keep the checkbox unchecked and use the slider to tell to ObjectNet to disable this script only after a certain amount of time. [PreviousSynchronization Options](https://onlineobject.gitbook.io/objectnet/general/network-components/network-prefabs/synchronization-options) [NextChild Objects](https://onlineobject.gitbook.io/objectnet/general/network-components/network-prefabs/child-objects) --- # Child Objects | ObjectNet Network Prefabs can often include multiple nested objects under a root GameObject. When a prefab is running in **Passive mode**, ObjectNet allows you to **disable specific child objects**. This is useful when certain parts of the object are only relevant to the owning client. To configure this, click the **script icon** as shown bellow to display a list of all child objects. You can then toggle which ones should be active or inactive when the prefab is passive. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2F3009462755-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FNG75ky1pR1kRokWLRnzy%252Fuploads%252FBf2mNLtCelV5jQzOjpg4%252FScreenshot%25202025-04-19%2520222812.png%3Falt%3Dmedia%26token%3Daecf597a-00c0-4d4f-96aa-1d54cea32d82&width=768&dpr=4&quality=100&sign=f195eae1&sv=2) By flagging the check box you can enable objects on passive instances. In case any child needs to be executed before being disabled ( if some data was collected in OnAwake on OnStart methods attached to this object ) you shall keep the checkbox unchecked and use the slider to tell to ObjectNet to disable only after a certain amount of time. * * * Click the icon on the left to expand and view all child objects. You can also use the **Smart Filter** search bar to quickly locate specific objects within the hierarchy. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2F3009462755-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FNG75ky1pR1kRokWLRnzy%252Fuploads%252FZ2OBPQNZ60pY6T2jIk4Z%252FScreenshot%25202025-04-19%2520222715.png%3Falt%3Dmedia%26token%3Dc0f3b23c-866b-4e3f-a811-8f52c4b7f2ac&width=768&dpr=4&quality=100&sign=f16915e2&sv=2) * * * Click the icons bellow to sync position, rotation or scale on any child object. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2F3009462755-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FNG75ky1pR1kRokWLRnzy%252Fuploads%252FnZkSDfzO6rVSGcsI59lT%252FScreenshot%25202025-07-27%2520110840.png%3Falt%3Dmedia%26token%3D045758b4-2342-48bc-89fc-2976c5c7434d&width=768&dpr=4&quality=100&sign=d4429f0c&sv=2) [PreviousPrefab Scripts](https://onlineobject.gitbook.io/objectnet/general/network-components/network-prefabs/prefab-scripts) [NextPrefab Scripts ( Remote Input )](https://onlineobject.gitbook.io/objectnet/general/network-components/network-prefabs/prefab-scripts-remote-input) Last updated 3 months ago --- # Prefab Scripts ( Remote Input ) | ObjectNet When Remote Input is enabled, Network Prefabs can behave differently from his normal behavior since the local player is running his player prefab on passive mode and sending input only. ObjectNet automatically disables all scripts when the game object is in passive mode, although in this specific case, some script needs to be executed, one example is the script that executes Input Checks ( for example ), otherwise Network Inputs will not be sent to the server. Script over Remote input can be enabled/disabled by clicking on an icon. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem141.png&width=300&dpr=4&quality=100&sign=446eb143&sv=2) A list of all scripts on each game object ( including children) will appear, and you can enable/disable any script. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem142.png&width=768&dpr=4&quality=100&sign=2be5b724&sv=2) By flagging the check box you can enable the script to run on passive instances. In case any script needs to be executed before being disabled ( if some data was collected in OnAwake on OnStart methods ) you shall keep the checkbox unchecked and use the slider to tell to ObjectNet to disable this script only after a certain amount of time. In the example below, the script "ControllerPlayerCharacter" will only be disabled after 20 ms of object creation. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem138.png&width=768&dpr=4&quality=100&sign=992c02f7&sv=2) [PreviousChild Objects](https://onlineobject.gitbook.io/objectnet/general/network-components/network-prefabs/child-objects) [NextScript Variables](https://onlineobject.gitbook.io/objectnet/general/network-components/network-prefabs/script-variables) --- # Network Events Manager | ObjectNet ObjectNet provide a embedded system to make easy to developer to handle with events. NetworkEventsManager allow user to manage events of two types. * Global Events * Custom Events ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem146.png&width=768&dpr=4&quality=100&sign=5e25b780&sv=2) ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fcontent.gitbook.com%2Fcontent%2FNG75ky1pR1kRokWLRnzy%2Fblobs%2FSgtme7w2xkdw0sC39uf4%2FScreenshot%25202025-04-17%2520113805%2520copy.png&width=768&dpr=4&quality=100&sign=a3d4fa41&sv=2) Logos Explained [PreviousScript Variables](https://onlineobject.gitbook.io/objectnet/general/network-components/network-prefabs/script-variables) [NextGlobal Events](https://onlineobject.gitbook.io/objectnet/general/network-components/network-events-manager/global-events) --- # Script Variables | ObjectNet ObjectNet provides the facility to automatically synchronize variables across the network. This can be very useful to avoid a lot of events to keep objects updated. Network Variables are synchronized from Active to Passive instance, this means that a variable modified on the Active instance will be sent over the network and applied on all Passive instances. Script Variables tap can be open/close by clicking on the variables icon. A list of all variables on the main NetworkObject component shall appear and you can enable/disable any script variable. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fcontent.gitbook.com%2Fcontent%2FNG75ky1pR1kRokWLRnzy%2Fblobs%2FI2VcEGgABa87jAUHGw8O%2Fimage.png&width=768&dpr=4&quality=100&sign=aa1c0cbd&sv=2) By flagging the check box you can enable variable synchronization across the network. Network Variables is available only for scripts inherited from NetworkBehavior, if the script was not inherited from NetworkBehavior is not possible to synchronize variable values ( see [Network Variables](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/network-variables) ). Check [Variables DeliveryModes:](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/network-variables#variables-deliverymodes) to learn more about the diffrence between Reliable and Unreliable variables and when to use them [PreviousPrefab Scripts ( Remote Input )](https://onlineobject.gitbook.io/objectnet/general/network-components/network-prefabs/prefab-scripts-remote-input) [NextNetwork Events Manager](https://onlineobject.gitbook.io/objectnet/general/network-components/network-events-manager) --- # Global Events | ObjectNet ObjectNet considers a Global Event, all events related to internal engine control. NetworkEventsManager allows the user to catch those events and implement any custom logic. Currently, NetworkEventsManager is allowed to listen to the following global events : Event Explained **OnServerStarted** triggered when server initialize his connection and start to listen for clients **OnConnected** triggered when the client successfully connects to the server. **OnDisconnected** triggered when the client disconnects from the server. **OnConnectedOnRelay** triggered when the client establishes a connection with a relay server. **OnServerRestarted** triggered when the client detects that the server has restarted. **OnConnectionFailed** triggered when the client fails to connect to the server. **OnLoginFailed** triggered when the client fails to log in to the server. **OnLoginSucess** triggered when the client successfully logs in to the server. **OnClientConnected** triggered when a new client connects to the server. **OnClientDisconnected** triggered when a client disconnects from the server. **OnClientLoginFailed** triggered when a client attempts to log in with invalid credentials. **OnClientLoginSucess** triggered when a client successfully logs in to the server **OnMessageReceived** triggered when a message is received by either the client or the server. **OnLobbyCreationSucess** triggered when the client successfully creates a lobby. **OnLobbyCreationFailed** triggered when the client fails to create a lobby. **OnLobbyJoinSucess** triggered when the client successfully joins a lobby **OnLobbyJoinFailed** triggered when the client fails to join a lobby. **OnLobbyPlayersRefresh** triggered when the client recive lobby players list **OnPlayerSpawned** triggered when some player get spawned **OnPlayerStarted** triggerd when some player start hist network instance **OnPlayerOwnerDetected** triggered when the client becomes owner of his player **OnSceneLoadFinished** triggered when all clients in the same match load a scene **OnSceneUnLoadFinished** triggered when all clients in the same match unload a scene **OnConnectionIdAssigned** triggered just after client receive his connection id from server **Red Color:** Events that only trigger on the **Server** ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2F3009462755-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FNG75ky1pR1kRokWLRnzy%252Fuploads%252F6hZG9MSplG3CWbnxqKTV%252FScreenshot%25202025-04-19%2520230203.png%3Falt%3Dmedia%26token%3Df60724f7-05b5-4d87-9af3-286f3c2a03a0&width=300&dpr=4&quality=100&sign=172c7559&sv=2) **Blue Color:** Events that only trigger on the **Clients** ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2F3009462755-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FNG75ky1pR1kRokWLRnzy%252Fuploads%252FZuSV6eY2AZOLsfbmCdiT%252FScreenshot%25202025-04-19%2520230214.png%3Falt%3Dmedia%26token%3Dc08e558b-15bc-4b80-9c3b-9d81384a99ce&width=300&dpr=4&quality=100&sign=b846879e&sv=2) **Yellow Color:** Triggered on both **Server** and **Clients** ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2F3009462755-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FNG75ky1pR1kRokWLRnzy%252Fuploads%252FgrxyckVxtAjcBpst2wav%252Fimage.png%3Falt%3Dmedia%26token%3D55829948-5871-4286-8e0a-bd3e7dfc6f0d&width=300&dpr=4&quality=100&sign=65852144&sv=2) Full detailed information can be found on API documents. You can find a full example of how to implement global events listener on "**15 - Global Events**" scene. [PreviousNetwork Events Manager](https://onlineobject.gitbook.io/objectnet/general/network-components/network-events-manager) [NextCustom Events](https://onlineobject.gitbook.io/objectnet/general/network-components/network-events-manager/custom-events) Last updated 7 months ago --- # Custom Events | ObjectNet ObjectNet allows developers to create, listen, and send custom events managed by NetworkEventsManager. NetworkEventsManager allows users to create customized events to catch the specific events of their game. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem147.png&width=768&dpr=4&quality=100&sign=2c15de5&sv=2) You can find a full example of how to implement custom events on "16 - Global Events" scene. Registering Event[](https://onlineobject.gitbook.io/objectnet/general/network-components/network-events-manager/custom-events#registering-event) To register a new event you need to select NetworkEventsManager and click on Event Editor button. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem148.png&width=768&dpr=4&quality=100&sign=295ee3e&sv=2) A new Events Database window shall appear : ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem149.png&width=768&dpr=4&quality=100&sign=eee3dc4b&sv=2) Fill the event name and press "Register Event" ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem150.png&width=768&dpr=4&quality=100&sign=cf6f09b9&sv=2) A new event shall appear on events list. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem151.png&width=768&dpr=4&quality=100&sign=48831434&sv=2) Each event will have its own unique code, this code is an Integer that is used to identify events over the network. User Event[](https://onlineobject.gitbook.io/objectnet/general/network-components/network-events-manager/custom-events#user-event) User Event is the way to NetworkEventsManager allows the user to listen when some custom event arrives. Select the event that you wish to listen to and click on "Register event to listen". ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem152.png&width=768&dpr=4&quality=100&sign=26ffc53&sv=2) The selected event will be registered. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem153.png&width=768&dpr=4&quality=100&sign=8dd077a6&sv=2) Now you need to select the action to take when this event arrives. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem154.png&width=768&dpr=4&quality=100&sign=3d278075&sv=2) You can find a full example of how to implement custom events on "16 - Custom Events" scene. In this scene, you will find scripts and objects to clarify how to implement your own custom events. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem155.png&width=768&dpr=4&quality=100&sign=9f35dd50&sv=2) User Actions[](https://onlineobject.gitbook.io/objectnet/general/network-components/network-events-manager/custom-events#user-actions) User Action is how NetworkEventsManager allows the user to send vents when some status is reached. Fill in the action name and click on "Register Action" button. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem156.png&width=768&dpr=4&quality=100&sign=3673a5af&sv=2) The action will be registered on the User Actions list. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem157.png&width=768&dpr=4&quality=100&sign=4f38f0a2&sv=2) The first to do is select which event you wish to send when action is triggered. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem158.png&width=768&dpr=4&quality=100&sign=3a22fd41&sv=2) The next step is to decide when you wish to trigger this event, the possible values can be found on ActionExecutionMode ( see API ). ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem160.png&width=768&dpr=4&quality=100&sign=7ebb6358&sv=2) Now you need to assign the object and component to watch, this component must be a component that exists in scene . ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem161.png&width=768&dpr=4&quality=100&sign=1a92635d&sv=2) Now you to fill the expression that will be evaluated to check if this condition matches with the selected on ActionExecutionMode. On this part you can select component ( script ) attributes or function witch return allowed types. The system will evaluate this condition on each execution frame to check if condition is reached. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem162.png&width=768&dpr=4&quality=100&sign=c1f2af2a&sv=2) The last step ( when applicable ) is define witch values will be included on message when the selected event was send. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem163.png&width=768&dpr=4&quality=100&sign=4ef2deb7&sv=2) Those values will be included on event when ObjectNet send it over network, and must be read when message arrives. You can found a full example about how to implement custom events on "16 - Custom Events" scene. On this scene you will find scripts and objects to clarify how implement you own custom events. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem164.png&width=768&dpr=4&quality=100&sign=435d09bc&sv=2) [PreviousGlobal Events](https://onlineobject.gitbook.io/objectnet/general/network-components/network-events-manager/global-events) [NextNetwork Debugger](https://onlineobject.gitbook.io/objectnet/general/network-components/network-debugger) --- # Network Debugger | ObjectNet ObjectNet includes a built-in **Network Debugger Manager** to help developers monitor and troubleshoot networking behaviors in real-time. This tool provides runtime diagnostics that make debugging easier during development and playtesting. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fcontent.gitbook.com%2Fcontent%2FNG75ky1pR1kRokWLRnzy%2Fblobs%2F6wKYDgVUOZHqG2Q9Gs18%2Fimage.png&width=768&dpr=4&quality=100&sign=2499eaa3&sv=2) Show Debug Trace[](https://onlineobject.gitbook.io/objectnet/general/network-components/network-debugger#show-debug-trace) Enables internal engine logs in the Unity Console. * Useful for inspecting internal events and messages. * Includes logs, warnings, and errors from ObjectNet. > Disable this option if you prefer a cleaner console output. Show Logs on Screen[](https://onlineobject.gitbook.io/objectnet/general/network-components/network-debugger#show-logs-on-screen) Displays diagnostic logs directly on the game screen — even during play mode or in a built build. * Helps track logs without needing to check the Unity Console. * Supports toggling individual categories: * ✅ Show Logs * ⚠️ Show Warnings * ❌ Show Errors Display Network Traffic[](https://onlineobject.gitbook.io/objectnet/general/network-components/network-debugger#display-network-traffic) Visualizes the amount of data being sent and received over the network. * Helps analyze bandwidth usage and detect performance issues. * **Analysis Interval (sec)**: Sets how frequently data is collected and visualized. Show Gizmos[](https://onlineobject.gitbook.io/objectnet/general/network-components/network-debugger#show-gizmos) Displays network-related gizmos in the Unity Scene view. * Useful for identifying and interacting with networked objects visually. The Network Debugger Manager is an essential tool for: * Realtime network performance analysis * On-screen logging in both editor and builds * Fine-tuning and troubleshooting multiplayer behavior Use it during development to **catch issues early** and optimize your network logic with confidence. [PreviousCustom Events](https://onlineobject.gitbook.io/objectnet/general/network-components/network-events-manager/custom-events) [NextNetwork Behaviour](https://onlineobject.gitbook.io/objectnet/general/network-behaviour) --- # Network Behaviour | ObjectNet ObjectNet provides a special class that can be extended to provide a bunch of events and methods, this class is NetworkBehaviour. The NetworkBehaviour is a class that replaces Unity MonoBehaviour class and provides a lot of embedded methods and events. NetworkBehavour can be used even if your game doesn't implement MultiPlayer features, this means if your game must work on the single-player mode you can keep this inheritance without affecting your single-player mode behavior. This is pretty useful since the developer can create your game to run in Single-player mode and multi-player while keeping the same code base. To extend your MonoBehaviour script from NetworkBehaviour it's just change inheritance. Copy public class MyGameScript : NetworkBehaviour { // Your class code } Once inherited, you can implement some special method to handle your multiplayer game, the following script will illustrate the main methods: To use `NetworkBehaviour` functionality in multiplayer, the object must be **registered as a** `**NetworkObject**` in the **NetworkManager's Prefab Database**. OnNetworkStarted[](https://onlineobject.gitbook.io/objectnet/general/network-behaviour#onnetworkstarted) This event is called once when Network is available to this object. Copy /// /// This event is called when Network features starts /// /// Note : This event is controlled internally by framework and ensure that /// network is up and running /// public override void OnNetworkStarted() { // Here you can do any that you need after ensure that Network is initialized } Awake[](https://onlineobject.gitbook.io/objectnet/general/network-behaviour#awake) Active Awake: This event is the Awake execute only when object is running on Active Mode. Copy /// /// Active Awake is executed when objects on Active mode Awake /// public void ActiveAwake() { } Passive Awake: This event is the Awake execute only when object is running on Passive Mode. Copy /// /// Passive Awake is executed when objects on Passive mode Awake /// public void PassiveAwake() { } Start[](https://onlineobject.gitbook.io/objectnet/general/network-behaviour#start) Active Start: This event is the Start execute only when object is running on Active Mode. Copy /// /// Active Start is executed when objects on Active mode Start /// public void ActiveStart() { } Passive Start: This event is the Start execute only when object is running on Passive Mode. Copy /// /// Passive Start is executed when objects on Passive mode Start /// public void PassiveStart() { } OnEnable[](https://onlineobject.gitbook.io/objectnet/general/network-behaviour#onenable) Active OnEnable: This event is the OnEnable execute only when object is running on Active Mode. Copy /// /// Active OnEnable is executed when objects on Active mode /// public void ActiveOnEnable() { } Passive OnEnable: This event is the OnEnable execute only when object is running on PassiveMode. Copy /// /// Active OnEnable is executed when objects on Passive mode /// public void PassiveOnEnable() { } OnDisable[](https://onlineobject.gitbook.io/objectnet/general/network-behaviour#ondisable) Active OnDisable: This event is the OnDisable execute only when object is running on ActiveMode. Copy /// /// Active OnDisable is executed when objects on Active mode /// public void ActiveOnDisable() { } Passive OnDisable: This event is the OnDisable execute only when object is running on PassiveMode. Copy /// /// Passive OnDisable is executed when objects on Passive mode /// public void PassiveOnDisable() { } Update[](https://onlineobject.gitbook.io/objectnet/general/network-behaviour#update) Active Update: This event is the Update execute only when object is running on Active Mode. Copy /// /// Active Update is executed every frame for Active object /// public void ActiveUpdate() { } Passive Update: This event is the Update execute only when object is running on Passive Mode. Copy /// /// Passive Update is executed every frame for Passive object /// public void PassiveUpdate() { } FixedUpdate[](https://onlineobject.gitbook.io/objectnet/general/network-behaviour#fixedupdate) Active FixedUpdate: This event is the FixedUpdate execute only when object is running on Active Mode. Copy /// /// Active FixedUpdate is executed every physics frame for Active object /// public void ActiveFixedUpdate() { } Passive FixedUpdate: This event is the FixedUpdate execute only when object is running on Passive Mode. Copy /// /// Passive FixedUpdate is executed every physics frame for Passive object /// public void PassiveFixedUpdate() { } LateUpdate[](https://onlineobject.gitbook.io/objectnet/general/network-behaviour#lateupdate) Active LateUpdate: This event is the LateUpdate execute only when object is running on Active Mode. Copy /// /// Active LateUpdate is executed every frame after Update for Active object /// public void ActiveLateUpdate() { } Passive LateUpdate: This event is the LateUpdate execute only when object is running on Passive Mode. Copy /// /// Passive LateUpdate is executed every frame after Update for Passive object /// public void PassiveLateUpdate() { } ### [](https://onlineobject.gitbook.io/objectnet/general/network-behaviour#example) Example: Here is an example on how to use them Copy public class MyGameScript : NetworkBehaviour { public override void OnNetworkStarted() { Debug.Log("Network is Initialized"); } public void ActiveStart() { Debug.Log("This is an Active Object"); } public void PassiveStart() { Debug.Log("This is a Passive Object"); } } [PreviousNetwork Debugger](https://onlineobject.gitbook.io/objectnet/general/network-components/network-debugger) [NextOwnership](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/ownership) Last updated 6 months ago --- # Network Methods | ObjectNet Network Method allows to execute methods over the network, this can be a powerful mechanism to keep you game synchronized and handle with aspects of your multiplayer game. Your scripts need to inherit from the `**NetworkBehaviour**` class, which is part of the `**com.onlineobject.objectnet**` namespace. Read [Network Behaviour](https://onlineobject.gitbook.io/objectnet/general/network-behaviour) for more information on this topic. * * * [](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/network-methods#server-and-clients) Server and Clients: ----------------------------------------------------------------------------------------------------------------------------------- You can execute any method on all players (Server - Host and Clients) using NetworkExecute(MethodName) anywhere in the same class. in the example bellow all players console will display Hello World! log. Copy // You class must have a method void MethodName() { Debug.Log("Hello World!"); } // And in any part of you code on the same class you can have this.NetworkExecute(this.MethodName); * * * [](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/network-methods#server-only) Server Only: --------------------------------------------------------------------------------------------------------------------- But in some cases you might need to execute a method solely on the server using NetworkExecuteOnServer(MethodName) this will ensure only the (server-host) will trigger the method. Copy // Execute method on server only this.NetworkExecuteOnServer(this.MethodName); * * * [](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/network-methods#clients-only) Clients Only: ----------------------------------------------------------------------------------------------------------------------- In other cases the server may need to execute a method on all clients execluding it self using NetworkExecuteOnClient(MethodName). this can only be called by the server-host. Copy // Execute method on all clients this.NetworkExecuteOnClient(this.MethodName); * * * [](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/network-methods#using-parameters) Using Parameters: ------------------------------------------------------------------------------------------------------------------------------- ObjectNet also allow to execute methods with parameters if needed. Copy // You class must have a method void MethodName(string name, int age) { // Do something } // And in any part of you code at same class you can have this.NetworkExecute(this.MethodName, "MyName", 20); _You can execute methods with up to 10 arguments. if you needed more than that you will have to use DataStream to send it mannually._ Supported Parameters types[](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/network-methods#supported-parameters-types) NetworkMethods support only theses types of data. Copy int uint long ulong short ushort float double ------------------------------------------------------------- byte sbyte byte[] bool string char char[] enum ------------------------------------------------------------- Vector2 Vector3 Vector4 Quaternion Color Matrix4x4 If you want to send custom data types then use [Events](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/sending-events) with [Custom DataStream](https://onlineobject.gitbook.io/objectnet/advance/custom-datastream) * * * [](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/network-methods#faq) FAQ: ----------------------------------------------------------------------------------------------------- How can I target only the Active ?[](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/network-methods#how-can-i-target-only-the-active) But what about if you want to target the Active player only, here is a quick tip to how to utilize NetworkExecute and [Ownership](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/ownership) to do that. Copy // You class must have a method void MethodName() { if (isActive()) { //ensures that only the active object execute the method Debug.Log("Am the Owner of this object"); } } // And in any part of you code on the same class you can have this.NetworkExecute(this.MethodName); Can I target methods outside the class ?[](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/network-methods#can-i-target-methods-outside-the-class) NetworkExecute only works on Methods inside the class but here is a work around for that: Copy using UnityEngine; using com.onlineobject.objectnet; public class Player: NetworkBehaviour { //Refrence to the Test Class private Test test; //Or in any part of you code private void Start(){ NetworkExecute(TestMessage); } //Trigger the method on the Test class private void TestMessage(){ test.Hello(); } } --------------------------------------------------------------- public class Test: MonoBehaviour { public void Hello(){ Debug.Log("Hello World"); } } As you can observe from the example above, you can Only NetworkExecute methods on the same Class, exectuing it directly like this _**NetworkExecute(test.Hello);**_ will not work because the method belongs to another class . Can I execute annonymus methods ?[](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/network-methods#can-i-execute-annonymus-methods) Executing Annonymus methods will not work for example _**NetworkExecute(() ⇒ Debug.Log(""));**_ wont work because NetworkExecute needs a method name to sync across the network and annonymus methods dont provide that. * * * [PreviousOwnership](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/ownership) [NextNetwork Variables](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/network-variables) Last updated 7 months ago --- # Ownership | ObjectNet In **ObjectNet**, ownership is the cornerstone of how network objects are controlled and synchronized across all clients. Ownership determines which client actively controls an object and how other clients passively interact with it. To provide clarity and ensure smooth gameplay, ObjectNet defines ownership in terms of **Active** and **Passive** states. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2F3009462755-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FNG75ky1pR1kRokWLRnzy%252Fuploads%252FRjthgb6wdi1UAZgk8cXm%252FActive%2520x%2520Passive%2520gif.gif%3Falt%3Dmedia%26token%3D85627de8-6266-4e2e-8b39-d7ce0eec0a69&width=768&dpr=4&quality=100&sign=81cbf8ff&sv=2) * * * [](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/ownership#active) **Active** -------------------------------------------------------------------------------------------------------- A client with **Active Ownership** is responsible for directly controlling the network object. This means: * They dictate the object's behavior (e.g., position, actions, animations). * They send updates to the network so other clients can stay synchronized. An object in the **Active** state is fully controlled by its owner, ensuring minimal latency and the most responsive experience for the controlling player. **Example:** Imagine a multiplayer racing game: * Player A owns and drives a car. As the **Active Owner**, Player A decides the car’s movements (steering, acceleration, braking) and updates the server with the car’s state. * Player A's inputs are sent to the server, which then propagates these updates to other players. You can check if a `NetworkObject` is in the **Active State** (meaning you own and control the object) by using `**isActive()**`. * * * [](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/ownership#passive) **Passive** ---------------------------------------------------------------------------------------------------------- All other clients are in a **Passive State** for objects they do not own. Clients in this state: * Cannot control the object directly. * Receive updates from the active owner to represent the object accurately on their side. The passive representation ensures all players can see the object’s latest state (e.g., position, speed, or visual effects) without conflicting with the active owner’s control. **Example:** In the same racing game: * Player B and Player C observe Player A's car as it moves around the track. * Their clients receive updates from Player A, which synchronize the car’s position, speed, and direction. Player B and Player C display these updates without directly modifying the car’s state To check if a `NetworkObject` is in the **Passive State** (meaning you are not the owner and only receive updates), you can use the `**isPassive()**` * * * Your scripts need to inherit from the `**NetworkBehaviour**` class, which is part of the `**com.onlineobject.objectnet**` namespace. Read [Network Behaviour](https://onlineobject.gitbook.io/objectnet/general/network-behaviour) for more information on this topic. Code Example[](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/ownership#code-example) Copy using UnityEngine; using com.onlineobject.objectnet; public class OwnerShipExample : NetworkBehaviour { public override void OnNetworkStarted() { // Check if the object is in the Active State (you own it) if(isActive()){ Debug.Log("I have Authority over this object"); } // Check if the object is in the Passive State (you do not own it) if(isPassive()){ Debug.Log("I have no Authority over this object"); } } } * * * [](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/ownership#dynamic-ownership-transfer) **Dynamic Ownership Transfer** ------------------------------------------------------------------------------------------------------------------------------------------------ ObjectNet supports dynamic ownership transfer, which is crucial for flexible gameplay scenarios. Ownership can be reassigned between clients as needed: * **Disconnection:** If the active owner disconnects, another client automatically takes over to maintain control of the object. * **Gameplay Mechanics:** Certain scenarios, such as passing a ball in a sports game or handing over an item in a co-op game, may require ownership to be transferred from one client to another dynamically. **Example:**[](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/ownership#example) In a multiplayer basketball game: * Player A owns the ball and is actively dribbling it. Other players are in the passive state, observing the ball’s movement. * When Player A passes the ball to Player B, ownership transfers to Player B. Player B now has **Active Ownership**, while Player A and others move into the passive state. To be able to transfere authority the NetworkObject OwnerShip Access Level need to be set to "Full" and OwnerShip working mode to "Use Prefab Definition" or "Allowed". ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fcontent.gitbook.com%2Fcontent%2FNG75ky1pR1kRokWLRnzy%2Fblobs%2FRpi5JZhhQHTbNfURIdJB%2FScreenshot%25202025-01-17%2520151241.png&width=768&dpr=4&quality=100&sign=cbeaea4&sv=2) ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fcontent.gitbook.com%2Fcontent%2FNG75ky1pR1kRokWLRnzy%2Fblobs%2Fytfhh8D9HXwUMCpcKI4T%2FScreenshot%25202025-01-17%2520151837.png&width=768&dpr=4&quality=100&sign=2fe1ef05&sv=2) you can find it on the NetworkManager gameobject ### [](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/ownership#code-implementation) Code Implementation You can Take the OwnerShip of a passive NetworkObject using `TakeControl()` method, it will change the authority state of the NetworkObject from Passive to Active on the Client that calls it, And set it to Passive on all other clients. Copy //Takes the authority over the NetworkObject TakeControl(); Copy //transfere the controls to another player using players Network ID TransferControl(int playerNetworkID); Copy //returns the control back to the server ReleaseControl(); Note: TakeControl() will automatically configure the object for **Active mode**, enabling relevant scripts and setting the Rigidbody accordingly. The previously active instance will also be updated to reflect **Passive mode**, with its components adjusted as needed. * * * Why This System Matters[](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/ownership#why-this-system-matters) The **Active** and **Passive** ownership model in ObjectNet ensures: * **Responsive Gameplay:** The active owner enjoys full control without interference from other clients. * **Accurate Representation:** All other clients see consistent and synchronized object states. * **Network Efficiency:** Passive clients only receive updates, reducing bandwidth usage and avoiding conflicts. * **Dynamic Flexibility:** Ownership can shift dynamically to accommodate gameplay needs, ensuring seamless transitions. By clearly defining ownership in terms of **Active** and **Passive** states, ObjectNet provides a robust framework for managing network objects in multiplayer environments, making it intuitive for developers and efficient for gameplay. [PreviousNetwork Behaviour](https://onlineobject.gitbook.io/objectnet/general/network-behaviour) [NextNetwork Methods](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/network-methods) Last updated 6 months ago --- # Despawn Objects | ObjectNet ObjectNet allows despawning of networkobject across the network. The script does **not** need to be inheriting from Network Behaviour for it to work, you can spawn and despawn on any Unity C# scripits. [](https://onlineobject.gitbook.io/objectnet/general/spawn-and-despawn/despawn-objects#despawning-on-the-server) Despawning on the Server ---------------------------------------------------------------------------------------------------------------------------------------------- On the **server** (or host), you can despawn network objects using Unity's standard `**Destroy()**` method. ObjectNet's built-in detection system will automatically recognize when a **NetworkObject** is destroyed and synchronize it across all connected clients. This makes it easy to use Unity’s native object creation workflow for networked objects. Alternatively, you can use ObjectNet's dedicated `NetworkGameObject.NetworkDestroy();` method for similar results. Copy // Using Unity's Instantiate method GameObject.Destroy(this.gameObject); // OR using ObjectNet's NetworkGameObject.Instantiate NetworkGameObject.NetworkDestroy(this.gameObject); Both methods will ensure the object is destroyed on all clients and properly synchronized. [](https://onlineobject.gitbook.io/objectnet/general/spawn-and-despawn/despawn-objects#despawning-on-clients) Despawning on Clients ---------------------------------------------------------------------------------------------------------------------------------------- On **clients**, ObjectNet's automatic detection system does not apply. This means that simply using Unity’s `**Destroy()**`method will only destroy the object locally and will not destroy it on other clients. To despawn an object across all clients from a **non-server** instance, you must use `NetworkGameObject.NetworkDestroy();`. This explicitly informs the server to handle the object creation and propagate it to all other connected clients. Copy // Using ObjectNet to despawn the network object on all clients NetworkGameObject.NetworkDestroy(this.gameObject); This ensures the object is properly destroyed across the network, regardless of whether the request originated from the server or a client. [PreviousSpawn Objects](https://onlineobject.gitbook.io/objectnet/general/spawn-and-despawn/spawn-objects) [NextIn-Scene Objects](https://onlineobject.gitbook.io/objectnet/general/spawn-and-despawn/in-scene-objects) --- # Playing Audio | ObjectNet ObjectNet allows to play audio clips, sound or event over network. To play audio clips over network you need to use ObjectNet API you need to use the following code. Copy this.Audio.Play(this.runningAudioClip); This method will play the selected audio track locally and send audio clip information on an event over the network to be played on network instances. Important: This method is available only to classes inherited from NetworkBehaviour. Note: You can do the same or create a custom synchronization by using your own event. [PreviousManual Animations](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/manual-animations) [NextSending Events](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/sending-events) --- # Network Variables | ObjectNet [](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/network-variables#general) General: --------------------------------------------------------------------------------------------------------------- ObjectNet provides the facility to keep variables synchronized over the network. Those variables are automatically synchronized over the network from Active to Passive instances. **To implement Network Variables, the script must be inherited from** **NetworkBehaviour** Network variables can synchronize the following types: Copy int uint long ulong short ushort float double ------------------------------------------------------------- byte sbyte byte[] bool string char char[] enum ------------------------------------------------------------- Vector2 Vector3 Vector4 Quaternion Color Matrix4x4 can be used in two ways. * By NetworkPrefabs ( see [Script Variables](https://onlineobject.gitbook.io/objectnet/general/network-components/network-prefabs/script-variables) ) * By Code ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2F3009462755-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FNG75ky1pR1kRokWLRnzy%252Fuploads%252F9hDn9k4u3wQla3rmy6Yp%252FNetworkVariables.gif%3Falt%3Dmedia%26token%3Dd509b4a8-082f-48df-9e3f-a612c83b798b&width=768&dpr=4&quality=100&sign=4c453d05&sv=2) **By NetworkPrefabs Database example** * * * [](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/network-variables#network-variables-by-code) Network Variables by code: --------------------------------------------------------------------------------------------------------------------------------------------------- To use Network Variable in code they must bound a type NetworkVariable where T must be included into allowed types. Copy private NetworkVariable variable = 0; Once defined you can use it as if any other script variable Copy this.variable += 1; int variableValue = this.variable; This provides greater control and access to various callbacks you can leverage. Below are some examples: Detecting Changes[](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/network-variables#detecting-changes) You can detect when the object was updated on the passive instance to apply changes only when occur. Copy this.variable.OnValueChange((int oldValue, int newValue) => { Debug.Log($"Value was updated from {oldValue} to {newValue} "); }); Note: This will only be triggered on passive object Important: Modifying the value of a `NetworkVariable` **directly on a passive object** can disrupt its internal synchronization logic. This may prevent the `OnValueChanged` callback from being triggered in the future—even when a new value is received from the active owner. \*unless you used variable.SetValue() Synchronizing local variables[](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/network-variables#synchronizing-local-variables) ObjectNet allows to synchronization of network variables with local variables automatically. The following script allows you to keep a local variable synchronized with a network variable, no matter where you change the value, both variables will have the same value. Copy NetworkVariable variable = "Hello world"; string localVariable = "Start text"; this.variable.OnSynchonize(() => { return this.localVariable; }, (string value) => { this.localVariable = value; }); // In this case variable Network will also receive the new value "New value from local" this.localVariable = "New value from local"; // In this case local variable will also receive the new value "New value from Network Variable" this.variable = "New value from Network variable"; **Important:** Never modify the value of a networked variable on a **passive** object, especially if it uses **Reliable** DeliveryMode. This can interfere with the value sent from the **active** source and cause players to see different results (desync). * * * [](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/network-variables#variables-deliverymodes) Variables DeliveryModes: ----------------------------------------------------------------------------------------------------------------------------------------------- there are two Modes NetworkVariables uses **Reliable** and **Unreliable** [Delivery Mode](https://onlineobject.gitbook.io/objectnet/general/fundamentals/delivery-mode) . Reliable Variables Unreliable Variables Reliable variables send data only when it detects changes or when a new client join, This makes them ideal for **data that changes infrequently**, as they reduce bandwidth usage and ensure consistency. Avoid using Reliable mode for variables that change frequently (e.g., more than once per second), as it may overwhelm the network and introduce latency. #### [](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/network-variables#examples-of-reliable-variables) _Examples of Reliable variables:_ Health, Player name / username, Score / Points, Kill / death count (K/D), Game state (Win/Loss, Start Match, Pause), Quest or mission updates, Timers, lobby settings, Inventory items, map selection, Skins selection, Environmenatl states (e.g., doors open) , etc... By defalue all NetworkVaraibles will be using Reliable DelivaryMode Unreliable variables are sent At a **constant rate** through the network object’s update loop, Using a lightweight, **unreliable buffer,** making it fast for frequently changing variables (more than once per second constantly). Unreliable variable could arrive **out of order or not at all, making it bad for timers and critical game events** #### [](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/network-variables#examples-of-unreliable-variables) _Examples of Unreliable variables:_ Input, Position , Target Position, Rotation, Animation parameters, Aim direction / camera look Change Delievry Mode from Prefab Database[](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/network-variables#change-delievry-mode-from-prefab-database) You can change the Network Variable Delivary Mode from the Network Manager Prefab DataBase as shown in the second Image ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fcontent.gitbook.com%2Fcontent%2FNG75ky1pR1kRokWLRnzy%2Fblobs%2FhTif5MHJlMDJWtDQkxjS%2FScreenshot%25202025-04-16%2520210011.png&width=768&dpr=4&quality=100&sign=f5f6bf4a&sv=2) ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fcontent.gitbook.com%2Fcontent%2FNG75ky1pR1kRokWLRnzy%2Fblobs%2FsPG5Ltu7pQceRAqYPIns%2FScreenshot%25202025-04-16%2520210110.png&width=768&dpr=4&quality=100&sign=9b010fb3&sv=2) Change Delievry Mode in code[](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/network-variables#change-delievry-mode-in-code) You can change the Network variable Delivary Mode from Reliable to Unreliable through code Copy private NetworkVariable variable = 0; private void Awake(){ this.variable.SetDeliveryMode(DeliveryMode.Unreliable); } Note: You should only change Delivary Mode in Awake() changing it mid game may cause unexpected behavoiur * * * Changes Detection Mode (In Reliable Variables)[](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/network-variables#changes-detection-mode-in-reliable-variables) #### [](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/network-variables#automatic-detection-mode) 🛠️ Automatic Detection Mode By default, all `Reliable Variables`in ObjectNet use **Automatic Detection Mode**. In this mode, ObjectNet continuously monitors variable changes and efficiently **packs all detected changes into a single buffer**, reducing bandwidth usage and improving performance. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2F3009462755-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FNG75ky1pR1kRokWLRnzy%252Fuploads%252FfOTVQN0Tz41wmPmjN0Kq%252Fimage.png%3Falt%3Dmedia%26token%3D68d64dd5-618f-462a-ac10-7b84b2fd5346&width=768&dpr=4&quality=100&sign=51446ab7&sv=2) The detection rate is tied to the Object **send rate**, ensuring that: * Only variables with actual changes are included in the update buffer. * If no changes occur, **no network packets are sent**, optimizing traffic flow. * * * #### [](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/network-variables#manual-detection-mode) 🛠️ Manual Detection Mode When you mark a variable as **Manual Detection**, ObjectNet will not sync it automatically. The developer take full responsibility for sending these reliable variables by themself. To send all **Manual Reliable** variables across all objects use: Copy NetworkManager.Instance().DetectVariablesChanges(bool includeAutomatic = false); This method does **not immediately send variable data**. It simply Invalidate all variables, allowing them to be detected and included in the next regular send cycle. * * * 📝 **Note:** If you are using Warpped Variables you can force an individual variable to be included in the next synchronization cycle by calling: Copy variableName.Invalidate(); This manually flags the variable as changed, ensuring it is sent even if its value hasn't been modified. * * * [](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/network-variables#faq) FAQ: ------------------------------------------------------------------------------------------------------- What if I want to modify a variable from a passive object?[](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/network-variables#what-if-i-want-to-modify-a-variable-from-a-passive-object) You **cannot directly modify** a variable on a **passive** object, as the change will **not be synced** across other clients. To update the value correctly, you should **send an** **RPC** to the **active** object and let it handle the modification. This ensures that the update is properly synced for everyone. Copy NetworkVariable health = 100; // Anywhere in your code (on active or passive) NetworkExecute(Damage, 20); // This ensures the value is only changed by the active instance private void Damage(int damage){ if (IsActive()) health -= damage; } 💡 Even passive objects can call `NetworkExecute`, but the logic inside will only run on the active side — keeping everything in sync. [PreviousNetwork Methods](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/network-methods) [NextManual Animations](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/manual-animations) Last updated 6 months ago --- # Spawn and Despawn | ObjectNet In **ObjectNet**, spawning and despawning are essential operations for managing networked objects across all connected clients. These features ensure that when objects are created or destroyed, the changes are synchronized across the entire multiplayer session. Spawning and Despawning only applies to registered NetworkObjects to spawn a normal object across the network use Rpc's [Network Methods](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/network-methods) [](https://onlineobject.gitbook.io/objectnet/general/spawn-and-despawn#automatic-prefab-detection) Automatic Prefab Detection ---------------------------------------------------------------------------------------------------------------------------------- ObjectNet automatically detects when a **NetworkObject** is created on the **server**. Once the object is instantiated on the server, it sends a notification to all connected clients to spawn the same object, ensuring synchronization across the network. This functionality is powered by the `**NetworkInstantiateDetection**` script, which is automatically attached to all **NetworkObjects**. This script handles the detection and communication process seamlessly, so you don’t need to manually manage synchronization for networked objects. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fcontent.gitbook.com%2Fcontent%2FNG75ky1pR1kRokWLRnzy%2Fblobs%2FjmLtTI3DBYzwLWEo8hBK%2FScreenshot%25202025-01-18%2520004140.png&width=768&dpr=4&quality=100&sign=89816c8a&sv=2) [PreviousCommon Functions](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/common-functions) [NextSpawn Objects](https://onlineobject.gitbook.io/objectnet/general/spawn-and-despawn/spawn-objects) --- # Manual Animations | ObjectNet ObjectNet allows to manually animate objects instead using auto animation provided by Network Prefab ( see [Synchronization Options](https://onlineobject.gitbook.io/objectnet/general/network-components/network-prefabs/synchronization-options) ). Important: This methods are available only to classes inherited from NetworkBehaviour. To animate objects using ObjectNet API you need to use one of the following code. Copy //similar to unity animator.Play this.Animation.Play("clipName"); //similar to unity animtor.Crossfade this.Animation.CrossFade("ClipName", float normalizedTransitionDuration); //similar to unity animator.CrossFadeInFixedTime this.Animation.CrossFadeInFixedTime("ClipName", float fixedTransitionDuration); This method will play animation locally and send animation event over network to be played on network instances You can use **Manual Animations Api** with all animation sync Modes, including **UseController**, **UseParameters**, and **ManualControl**. See [Synchronization Options](https://onlineobject.gitbook.io/objectnet/general/network-components/network-prefabs/synchronization-options) ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2F3009462755-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FNG75ky1pR1kRokWLRnzy%252Fuploads%252FmYzaabGcHGK0to046bzF%252Fimage.png%3Falt%3Dmedia%26token%3D989f2e93-3049-4b5a-ac65-b26fea8e83bd&width=300&dpr=4&quality=100&sign=5d2cdd21&sv=2) Note: You can do the same or create a custom synchronization by using your own event. [PreviousNetwork Variables](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/network-variables) [NextPlaying Audio](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/playing-audio) Last updated 6 months ago --- # Spawn Objects | ObjectNet ObjectNet allows to spawn objects over network, when those objects are spawned all network peers will be notified to spawn the same object. The script does **not** need to be inheriting from Network Behaviour for it to work, you can spawn and despawn on any Unity C# scripits. [](https://onlineobject.gitbook.io/objectnet/general/spawn-and-despawn/spawn-objects#spawning-on-the-server) Spawning on the Server ---------------------------------------------------------------------------------------------------------------------------------------- On the **server** (or host), you can spawn network objects using Unity's standard `**Instantiate()**` method. ObjectNet's built-in detection system will automatically recognize when a **NetworkObject** is created and synchronize it across all connected clients. This makes it easy to use Unity’s native object creation workflow for networked objects. Alternatively, you can use ObjectNet's dedicated `**NetworkGameObject.NetworkInstantiate()**`method for similar results. Copy // Using Unity's Instantiate method GameObject.Instantiate(this.prefabToSpawn, this.spawnPosition, Quaternion.identity); // OR using ObjectNet's NetworkGameObject.Instantiate NetworkGameObject.NetworkInstantiate(this.prefabToSpawn, this.spawnPosition, Quaternion.identity); Both methods will ensure the object is created on all clients and properly synchronized. [](https://onlineobject.gitbook.io/objectnet/general/spawn-and-despawn/spawn-objects#spawning-on-clients) Spawning on Clients ---------------------------------------------------------------------------------------------------------------------------------- On **clients**, ObjectNet's automatic detection system does not apply. This means that simply using Unity’s `**Instantiate**` method will only create the object locally and will not synchronize it with other clients. To spawn an object across all clients from a **non-server** instance, you must use `**NetworkGameObject.NetworkInstantiate()**`. This explicitly informs the server to handle the object creation and propagate it to all other connected clients. Copy // Using ObjectNet to spawn the object on all clients NetworkGameObject.NetworkInstantiate(this.prefabToSpawn, this.spawnPosition, Quaternion.identity); This ensures the object is properly created and synchronized across the network, regardless of whether the request originated from the server or a client. [](https://onlineobject.gitbook.io/objectnet/general/spawn-and-despawn/spawn-objects#retrieveing-gameobject-reference) Retrieveing GameObject Reference ------------------------------------------------------------------------------------------------------------------------------------------------------------ When spawning a network object using **ObjectNet**, you can retrieve a reference to the instantiated **GameObject**. ObjectNet uses asynchronous operations to ensure the object is fully synchronized across the network before providing the reference. You can use the `**await**` keyword with the `**NetworkGameObject.Instantiate**` method to get the spawned object. This guarantees that the reference is ready and fully initialized for use. Copy public async void SpawnGameObjectExample()//note the method need to be async { // Spawn the object and retrieve its reference asynchronously GameObject spawnedObject = await NetworkGameObject.Instantiate(this.prefabToSpawn, this.spawnPosition, Quaternion.identity); } Using **async/await** with ObjectNet's `**NetworkGameObject.Instantiate**` ensures that your code is efficient, reliable, and synchronized across the network. Note: The instance returned from `await` may require one additional frame before network-related features are fully initialized. * * * [](https://onlineobject.gitbook.io/objectnet/general/spawn-and-despawn/spawn-objects#faq) FAQ: --------------------------------------------------------------------------------------------------- Why doesn’t the client have control over the object it spawns?[](https://onlineobject.gitbook.io/objectnet/general/spawn-and-despawn/spawn-objects#why-doesnt-the-client-have-control-over-the-object-it-spawns) By default, any `NetworkObject` created in the network is automatically **owned by the host**. This means the client that spawned the object does **not** have authority over it unless specified otherwise. To give control to the client that spawns the object, you have two options: * **Set the Access Level to Client-Only** This will ensure that the client automatically gains ownership of the objects that they instantiate. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2F3009462755-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FNG75ky1pR1kRokWLRnzy%252Fuploads%252FJux6Nko8Dp0qVsQb5Ec5%252Fimage.png%3Falt%3Dmedia%26token%3D733d8782-68b9-4f4f-bde5-67ae997f4e57&width=768&dpr=4&quality=100&sign=98dfa67a&sv=2) **NetworkObjects** with **ClientOnly** access level **do not support ownership transfer**. Once assigned, ownership cannot be changed. * * * * Alternatively, the client can manually request ownership of the spawned object by calling `TakeControl()` for example: Copy GameObject _spawnedObject = await NetworkGameObject.Instantiate(this.prefabToSpawn, this.spawnPosition, Quaternion.identity); _spawnedObject.GetComponent().TakeControl(); This allows **dynamic ownership** transfer after the object has been instantiated see [Dynamic Ownership Transfer](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/ownership#dynamic-ownership-transfer) for more details on this topic. [PreviousSpawn and Despawn](https://onlineobject.gitbook.io/objectnet/general/spawn-and-despawn) [NextDespawn Objects](https://onlineobject.gitbook.io/objectnet/general/spawn-and-despawn/despawn-objects) Last updated 6 months ago --- # In-Scene Objects | ObjectNet If a networked object already exists in the scene at the start of the game (i.e. not spawned at runtime), it's important to **mark it as an “In-Scene Object”**. Failing to do so can cause ObjectNet to mistakenly treat it as a runtime-spawned object, leading to **duplicate instances on other clients** and eventual **desynchronization**. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fcontent.gitbook.com%2Fcontent%2FNG75ky1pR1kRokWLRnzy%2Fblobs%2FPKRjxA5MDfm2xac5ShZX%2FScreenshot%25202025-04-16%2520220129.png&width=768&dpr=4&quality=100&sign=31f31d2c&sv=2) Do **not** enable **In-Scene Object** directly on the prefab itself. This option should only be enabled on the instance of the prefab placed in the scene. While enabling it at the prefab level may appear to work, it can cause **unexpected behaviors** during runtime and network synchronization. Each in-scene object **must have a unique Network ID**. ObjectNet relies on this ID to distinguish between networked objects. If two objects share the same ID, you may encounter unpredictable behavior and synchronization errors. [PreviousDespawn Objects](https://onlineobject.gitbook.io/objectnet/general/spawn-and-despawn/despawn-objects) [NextSpawn Player Manually](https://onlineobject.gitbook.io/objectnet/general/spawn-and-despawn/spawn-player-manually) Last updated 6 months ago --- # NetworkManager Functions | ObjectNet [Starting and Stopping Network](https://onlineobject.gitbook.io/objectnet/general/networkmanager-functions/starting-and-stopping-network) [Scene Managment](https://onlineobject.gitbook.io/objectnet/general/networkmanager-functions/scene-managment) [Sending Global Events](https://onlineobject.gitbook.io/objectnet/general/networkmanager-functions/sending-global-events) [Common Functions](https://onlineobject.gitbook.io/objectnet/general/networkmanager-functions/common-functions) [PreviousRespawn Player](https://onlineobject.gitbook.io/objectnet/general/spawn-and-despawn/respawn-player) [NextStarting and Stopping Network](https://onlineobject.gitbook.io/objectnet/general/networkmanager-functions/starting-and-stopping-network) --- # Spawn Player Manually | ObjectNet By default, **ObjectNet automatically spawns the player GameObject** when a client connects. However, you can override this behavior and take full control of the player spawning process. [](https://onlineobject.gitbook.io/objectnet/general/spawn-and-despawn/spawn-player-manually#manual-player-spawning) Manual Player Spawning ------------------------------------------------------------------------------------------------------------------------------------------------ To manually spawn the player, enable the **"Manually Spawn"** option in the `**NetworkManager**` settings. Once enabled, you are responsible for calling the spawn logic through code when you need it. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fcontent.gitbook.com%2Fcontent%2FNG75ky1pR1kRokWLRnzy%2Fblobs%2FURkpI59afV5cNV5OaQzM%2FScreenshot%25202025-04-16%2520231356.png&width=768&dpr=4&quality=100&sign=18b6661e&sv=2) Copy // Call this from anywhere in your code when you're ready to spawn the player NetworkManager.Instance().SpawnPlayer(); This will: * Spawn the **Player Prefab** assigned in the NetworkManager * Use the **Spawn Position** specified in the NetworkManager * Synchronize the spawn across **all clients** ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fcontent.gitbook.com%2Fcontent%2FNG75ky1pR1kRokWLRnzy%2Fblobs%2FWhLTYDHSPbPx8rYVTuFu%2FScreenshot%25202025-04-16%2520232333.png&width=768&dpr=4&quality=100&sign=a4559505&sv=2) ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fcontent.gitbook.com%2Fcontent%2FNG75ky1pR1kRokWLRnzy%2Fblobs%2F2UnX2Ywp12UHqywE0YP9%2FScreenshot%25202025-04-16%2520232351.png&width=768&dpr=4&quality=100&sign=238ac2be&sv=2) Make sure the **Player Prefab** and **Spawn Position** fields are properly set in the NetworkManager. If they are left empty, this call will result in a `NullReferenceException`. [](https://onlineobject.gitbook.io/objectnet/general/spawn-and-despawn/spawn-player-manually#custom-prefab-or-position) Custom Prefab or Position ------------------------------------------------------------------------------------------------------------------------------------------------------ You can also override the prefab and/or position, rotation programmatically: Copy // // Uses prefab passed in code, but still requires the position to be set in NetworkManager NetworkManager.Instance().SpawnPlayer(this.playerPrefab); // Full control: no need to set anything in NetworkManager NetworkManager.Instance().SpawnPlayer(this.playerPrefab, position); NetworkManager.Instance().SpawnPlayer(this.playerPrefab, position, rotation); //or set the player prefab to null to use the player prefab set by NetworkManager NetworkManager.Instance().SpawnPlayer(null, position, rotation); These overloads let you: * Spawn a custom Network prefab instead of the default one in the NetworkManager inspector * Choose custom spawn positions and rotations per player * Skip relying on `NetworkManager` settings entirely Note: You can spawn the player multiple times so make sure it is destroyed before spawning it again or else you will end up with duplicate's [PreviousIn-Scene Objects](https://onlineobject.gitbook.io/objectnet/general/spawn-and-despawn/in-scene-objects) [NextRespawn Player](https://onlineobject.gitbook.io/objectnet/general/spawn-and-despawn/respawn-player) Last updated 6 months ago --- # Scene Managment | ObjectNet ObjectNet provides a powerful system for **synchronously loading and unloading scenes** across all connected clients. This is essential for transitioning between game levels, zones, or UI states in a multiplayer environment. [](https://onlineobject.gitbook.io/objectnet/general/networkmanager-functions/scene-managment#remote-scene-loading) Remote Scene Loading --------------------------------------------------------------------------------------------------------------------------------------------- You can remotely load a scene on all clients using: Copy NetworkManager.Instance().LoadSceneRemote( string sceneName, RemoteSceneLoadMode serverLoadMode = RemoteSceneLoadMode.LoadAfter, LoadSceneMode loadMode = LoadSceneMode.Single, float loadTimeout = 10f ); Parameter Description sceneName The name of the scene to load ServerLoadMode Whether the **server loads first or after** the clients _(Default:_ `_LoadAfter_`_), either way they both will open the scene simultaniously_ LoadMode Unity’s scene load type (`Single` or `Additive`) LoadTimeout Maximum time to wait for all clients to load their scenes, prevent clients from hanging if one fails to load Copy //example NetworkManager.Instance().LoadSceneRemote("Level1", RemoteSceneLoadMode.LoadAfter, LoadSceneMode.Single, 10); * * * [](https://onlineobject.gitbook.io/objectnet/general/networkmanager-functions/scene-managment#remote-scene-unloading) Remote Scene Unloading ------------------------------------------------------------------------------------------------------------------------------------------------- To unload a scene from all clients at once, use: Copy NetworkManager.Instance().UnloadSceneRemote( string sceneName, RemoteSceneUnloadMode serverUnloadMode = RemoteSceneUnloadMode.UnloadAfter, float loadTimeout = 10f ); Just like loading, the **server can wait for clients or unload first**, and a timeout ensures consistency across slower machines. * * * [](https://onlineobject.gitbook.io/objectnet/general/networkmanager-functions/scene-managment#important-notes) Important Notes ----------------------------------------------------------------------------------------------------------------------------------- * These methods **must be called from the server or host** * Scene names must be added to Unity's **Build Settings** * Timeouts prevent clients from hanging if one fails to load * Use `LoadSceneMode.Additive` if you want to keep the current scene loaded [PreviousStarting and Stopping Network](https://onlineobject.gitbook.io/objectnet/general/networkmanager-functions/starting-and-stopping-network) [NextManual Scene Load](https://onlineobject.gitbook.io/objectnet/general/networkmanager-functions/scene-managment/manual-scene-load) Last updated 7 months ago --- # Common Functions | ObjectNet Below are some commonly used methods available within the `NetworkBehaviour` class that can assist with implementing multiplayer logic. GetNetworkId()[](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/common-functions#getnetworkid) Each NetworkObject has its unique id thats how ObjectNet diffrentiate between diffrent objects on the scene. Copy int id = this.GetNetworkId(); HasNetworkElement()[](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/common-functions#hasnetworkelement) Check wheather the NetworkObject is initialized and NetworkElement was created Copy if(this.HasNetworkElement()){ } GetNetworkElement()[](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/common-functions#getnetworkelement) Returns the `INetworkElement` associated with the current `NetworkObject`. This provides access to a broader set of functions that allow you to control and customize the behavior of the networked object. Copy this.GetNetworkElement() SetActiveRate()[](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/common-functions#setactiverate) After retrieving the `INetworkElement`, you can use it to **dynamically adjust the send rate** of the associated `NetworkObject` by calling: Copy //change active send rate of this network object GetNetworkElement().SetActiveRate(int rate) //or change minmum send rate when no changes are detected only for that object GetNetworkElement().SetMinimunRateValue(int minimumRateValue) Pause and Resume Behaviours[](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/common-functions#pause-and-resume-behaviours) You can pause and resume Behaviours like Position sync, Animations sync, Variables sync. through code and resume them when ever you want. Copy //Pause this.GetNetworkElement().GetBehavior().Pause(); this.GetNetworkElement().GetBehavior().Pause(); this.GetNetworkElement().GetBehavior().Pause(); this.GetNetworkElement().GetBehavior().Pause(); this.GetNetworkElement().GetBehavior().Pause(); Copy //Resume this.GetNetworkElement().GetBehavior().Resume(); this.GetNetworkElement().GetBehavior().Resume(); this.GetNetworkElement().GetBehavior().Resume(); this.GetNetworkElement().GetBehavior().Resume(); this.GetNetworkElement().GetBehavior().Resume(); Teleport()[](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/common-functions#teleport) You can teleport the Networkobject without interpolating it on the passive. Copy this.Teleport(targetPosition); IsActive() and IsPassive()[](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/common-functions#isactive-and-ispassive) Determines whether the current NetworkObject is **Active** or **Passive** (a remote instance). For a detailed explanation of Active vs Passive objects, see [Ownership](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/ownership) . Copy if (IsActive()) { // This object is the data owner } if (IsPassive()) { // This object is a remote replica } IsRuningLogic()[](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/common-functions#isruninglogic) This checks if your current device is the **Host** — the one responsible for running all the **authoritative game logic**. > Think of this as: _"Am I in charge of running the game world?"_ Copy this.IsRunningLogic() IsOwner()[](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/common-functions#isowner) This is useful when useing [Remote Controls](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/remote-controls) as all objects will be passive on clients even player object, and the only way for clients to know if they own the player will be by using Copy if(this.IsOwner()){ } IsPlayer()[](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/common-functions#isplayer) Determines whether the object is a Player GameObject. Copy if (this.IsPlayer()){ } TakeControl()[](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/common-functions#takecontrol) Takes control over the passive object turining it to Active. Check [Dynamic Ownership Transfer](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/ownership#dynamic-ownership-transfer) for more details. Copy //Call on Passive TakeControl() Note: TakeControl() will automatically configure the object for **Active mode**, enabling relevant scripts and setting the Rigidbody accordingly. The previously active instance will also be updated to reflect **Passive mode**, with its components adjusted as needed. SetBehaviourMode()[](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/common-functions#setbehaviourmode) The `TakeControl()` method is used to switch a `NetworkObject` from **Passive** to **Active** mode. However, this process is **not instant** — it requires approval from the server before the mode change is applied. If you need to **immediately switch a local object to Active mode** (e.g., for instant responsiveness), you can do so by calling `SetBehaviorMode(BehaviorMode.Active)` directly after calling **TakeControl()**. This updates the local state immediately while still allowing `TakeControl()` to handle proper server-side ownership and passive transition of the previously active object. Here’s how to combine both calls for smooth control handoff: Copy // Notify the server to handle ownership changes this.TakeControl(); // Instantly switch the local object to Active mode without delay this.SetBehaviorMode(BehaviorMode.Active, false); //make sure to set the second parameter detectOnStart to false //just as shown in the example above or else it will trigger OnNetworkStart(). Use this approach carefully to avoid conflicts with server authority or synchronization logic. These are specific Methods in the NetworkBehaviour class, for a more global methods check Network Manager [Common Functions](https://onlineobject.gitbook.io/objectnet/general/networkmanager-functions/common-functions) For a complete list, refer to the [API Documentation](https://onlineobject.net/objectnet/docs/api/html/N-com.onlineobject.objectnet.htm) . [PreviousSending Events](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/sending-events) [NextSpawn and Despawn](https://onlineobject.gitbook.io/objectnet/general/spawn-and-despawn) Last updated 6 months ago --- # Respawn Player | ObjectNet ObjectNet provides built-in tools to **respawn players dynamically**. This is especially useful in scenarios such as: * Handling player death and revival * Resetting players during game state changes * Reloading or transitioning between scenes * * * [](https://onlineobject.gitbook.io/objectnet/general/spawn-and-despawn/respawn-player#on-the-server) On the Server ----------------------------------------------------------------------------------------------------------------------- When acting as the server, you have full control over all player objects and can trigger respawns directly. ### [](https://onlineobject.gitbook.io/objectnet/general/spawn-and-despawn/respawn-player#respawn-the-local-server-player) Respawn the Local Server Player Copy //you can call it anywhere NetworkManager.Instance().RespawnServerPlayer(); //or if you want more control over spawn position and rotation NetworkManager.Instance().SpawnPlayer(null, position, rotation); * Destroys the current server player object (if it exists) across all clients. * Spawns a new player instance using the prefab and spawn logic defined in `NetworkManager`. Respawn Any Connected Client[](https://onlineobject.gitbook.io/objectnet/general/spawn-and-despawn/respawn-player#respawn-any-connected-client) Copy //Should be only called by the Host NetworkManager.Instance().RespawnPlayer(IClient client); * Allows the server to respawn any player by passing their associated `IClient`. * * * [](https://onlineobject.gitbook.io/objectnet/general/spawn-and-despawn/respawn-player#on-the-client) On the Client ----------------------------------------------------------------------------------------------------------------------- Clients can **request a respawn** from the server. This is a permission-based operation — the server decides whether to approve and execute the respawn. ### [](https://onlineobject.gitbook.io/objectnet/general/spawn-and-despawn/respawn-player#request-respawn-while-player-is-alive) Request Respawn (While Player is Alive) Copy //calling it from inside the Active Player NetworkBehaviour NetworkManager.Instance().RequestPlayerRespawn(this.GetNetworkElement()); //or any where by using INetworkElement playerElement = NetworkManager.Instance().GetLocalPlayerElement() NetworkManager.Instance().RequestPlayerRespawn(playerElement); * Sends a request to the server to destroy the current player and spawn a new one. * Supports optional parameters to customize the spawn location and rotation: Copy //calling it from inside the Active Player NetworkBehaviour NetworkManager.Instance().RequestPlayerRespawn( this.GetNetworkElement(), null, newPosition, newRotation ); * * * [](https://onlineobject.gitbook.io/objectnet/general/spawn-and-despawn/respawn-player#respawn-when-player-is-already-destroyed) Respawn When Player is Already Destroyed ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- If the player object was already destroyed (e.g., during a scene load), you can Spawn as how you will in [Spawn Player Manually](https://onlineobject.gitbook.io/objectnet/general/spawn-and-despawn/spawn-player-manually) (this works for both host and clients) Copy //you can call it anywhere NetworkManager.Instance().SpawnPlayer(null, position, rotation); //Note: make sure the player is destroyed before calling SpawnPlayer or else //you will have dublicates This is typically used in cases where: * All players are removed during scene transitions * Players is destroyed and you need to instantiate it [PreviousSpawn Player Manually](https://onlineobject.gitbook.io/objectnet/general/spawn-and-despawn/spawn-player-manually) [NextNetworkManager Functions](https://onlineobject.gitbook.io/objectnet/general/networkmanager-functions) Last updated 7 months ago --- # Sending Events | ObjectNet This section explains how to **send and listen for events over the network** from a specific NetworkObject. Events dispatched this way will be **received on the corresponding NetworkObject instance across all clients**. If you’re looking to send **global events** that are not tied to a specific NetworkObject, please refer to the [Global Events](https://onlineobject.gitbook.io/objectnet/general/network-components/network-events-manager/global-events) section. [](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/sending-events#sending) Sending ----------------------------------------------------------------------------------------------------------- First, you need to create a unique identifier for this event, this identifier shall be a positive integer number. Copy const int LOCAL_CUSTOM_EVENT = 20000; Note: It's highly recommenced to group events to avoid two events using the same code Local events work exactly as Global Events, the main difference is that Object Event is sent having a NetworkObject as origin and will arrive on the same object in the client instance, this means that Object Event is a smart way to update or change a specific NetworkObject. This code illustrates how to send an event from an object over the network, you can include data on the message to be received on the target destination. Copy using (DataStream writer = new DataStream()) { writer.Write(this.transform.position); // Vector3 writer.Write(this.objectStatus); // int writer.Write(this.errorCode); // uint // Send event // Is important to send using "this" because system will include object information's during event send this.Send(LOCAL_CUSTOM_EVENT, writer, DeliveryMode.Reliable); } [](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/sending-events#listening) Listening --------------------------------------------------------------------------------------------------------------- You can listen to events sent by other network peers and execute some action based on this event, this event will arrive specifically on the same object where the event will be raised on the server or another remote player. This code illustrates how to listen to some network event from a NetworkObject, read data on this event, and take some action. Copy public override void OnNetworkStarted() { this.RegisterEvent(LOCAL_CUSTOM_EVENT, this.OnCustomEventReceivedOnObject); } private void OnCustomEventReceivedOnObject(IDataStream reader) { Vector3 receivedPosition = reader.Read(); float receivedStatus = reader.Read(); int receivedErrorCode = reader.Read(); // Update player with received information this.RaiseObjectError(receivedPosition, receivedStatus, receivedErrorCode); } Note: Register the event OnNetworkStarted to make sure the object is intialized or else it wont work. Full Code Example[](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/sending-events#full-code-example) Note: the script inherits from NetworkBehaviour class as we are sending Network Object Events. Sending global events dont need that (see [Sending Global Events](https://onlineobject.gitbook.io/objectnet/general/networkmanager-functions/sending-global-events) ) Copy using UnityEngine; using com.onlineobject.objectnet; public class SendEventExample : NetworkBehaviour { const int LOCAL_CUSTOM_EVENT = 20000; //Subscribe the reciever method to the event public override void OnNetworkStarted() { this.RegisterEvent(LOCAL_CUSTOM_EVENT, this.OnCustomEventReceivedOnObject); } private void Update(){ //makes sure only the active running this code if (IsPassive()) return; // sends the event when ever the user press T if (Input.GetKeyDown(KeyCode.T)){ using (DataStream writer = new DataStream()) { writer.Write(this.transform.position); // Vector3 writer.Write(this.objectStatus); // int writer.Write(this.errorCode); // uint // Send event // Is important to send using "this" because system will include object information's during event send this.Send(LOCAL_CUSTOM_EVENT, writer, DeliveryMode.Reliable); } } } //Event will trigger this method private void OnCustomEventReceivedOnObject(IDataStream reader) { Vector3 receivedPosition = reader.Read(); float receivedStatus = reader.Read(); int receivedErrorCode = reader.Read(); // Update player with received information this.RaiseObjectError(receivedPosition, receivedStatus, receivedErrorCode); } //regular method private void RaiseObjectError(Vector3 position, float status, ushort errorCode){ //any logic } } BroadCast[](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/sending-events#broadcast) When registering the event you have an option to broadcast the event to other clients. other wise the event will only be triggered on the server. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fcontent.gitbook.com%2Fcontent%2FNG75ky1pR1kRokWLRnzy%2Fblobs%2FsC7R7N4zX1MlW8yuL5vE%2FScreenshot%25202025-04-17%2520125225.png&width=768&dpr=4&quality=100&sign=ef3105f8&sv=2) This tells the server to propagate the message coming from one client to all other clients. Note: if the sender is the Server then all clients will recive the message regardless if broadcast was true or false, broadcast option is only for clients that want to communicate with other clients. Supported Data types[](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/sending-events#supported-data-types) You can include the following data types on the event message. Copy int uint long ulong short ushort float double ------------------------------------------------------------- byte sbyte byte[] bool string char char[] enum ------------------------------------------------------------- Vector2 Vector3 Vector4 Quaternion Color Matrix4x4 * * * [](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/sending-events#faq) FAQ: ---------------------------------------------------------------------------------------------------- Show me an Example on how to send a list using DataStream[](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/sending-events#show-me-an-example-on-how-to-send-a-list-using-datastream) Here is an example that illustrate the write and read of a full list. Copy private List Numbers = new List(); //any where in you script using (DataStream writer = new DataStream()){ //write the length of the list writer.Write(this.Numbers.Count); // int //write each value on the list for (int i = 0; i < Numbers.Count; i++){ writer.Write(Numbers[i]); } // Is important to send using "this" because system will include object information's during event send this.Send(LOCAL_CUSTOM_EVENT, writer, DeliveryMode.Reliable); } //On the reciver private void OnCustomEventReceivedOnObject(IDataStream reader){ //read the length int listLength = reader.Read(); //read and update each value on the list for (int i = 0; i < listLength; i++){ Numbers[i] = reader.Read(); } } Why the Event is not triggered on the sender?[](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/sending-events#why-the-event-is-not-triggered-on-the-sender) Events will **not be triggered on the sender**. Custom events are broadcast **to other clients**, not to the sender itself. When a client sends a `DataStream` message, the message is **not looped back to the sender**. This means the sender will **not receive or trigger the event locally**. If you want the sender to also process the logic, you’ll need to **manually invoke the logic** on the sender’s side after sending. Copy //for example using (DataStream writer = new DataStream()) { writer.Write(this.transform.position); // Vector3 writer.Write(this.objectStatus); // int writer.Write(this.errorCode); // uint // Send event // Is important to send using "this" because system will include object information's during event send this.Send(LOCAL_CUSTOM_EVENT, writer, DeliveryMode.Reliable); } //execute locally this.RaiseObjectError(this.transform.position, this.objectStatus, this.errorCode); [PreviousPlaying Audio](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/playing-audio) [NextCommon Functions](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/common-functions) Last updated 6 months ago --- # Starting and Stopping Network | ObjectNet [](https://onlineobject.gitbook.io/objectnet/general/networkmanager-functions/starting-and-stopping-network#starting-the-network) Starting the Network: ------------------------------------------------------------------------------------------------------------------------------------------------------------ To perform any networked operation—such as sending RPCs or synchronizing data—you must first **start the network**. This requires a running server, host, or client instance. ObjectNet provides both **automatic startup options** through the `NetworkManager` and full **manual control via code** if you prefer runtime configuration. ### [](https://onlineobject.gitbook.io/objectnet/general/networkmanager-functions/starting-and-stopping-network#automatic-startup-inspector) \- Automatic Startup (Inspector) In the `**NetworkManager**` component, you can configure the connection mode and startup behavior directly in the inspector: [Connections](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/connections) * **Connection Mode**: Choose between `Server`, `Client`. * **Connect on Start**: If enabled, the network will start automatically when the scene loads. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2F3009462755-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FNG75ky1pR1kRokWLRnzy%252Fuploads%252FOedQjWOiMHGxYjHnvNep%252Fimage.png%3Falt%3Dmedia%26token%3D23605aeb-720e-4eda-824f-4961a4e1b100&width=300&dpr=4&quality=100&sign=5a0e7242&sv=2) * * * ### [](https://onlineobject.gitbook.io/objectnet/general/networkmanager-functions/starting-and-stopping-network#manual-startup) \- Manual Startup If you uncheck **Connect on Start**, you can start the network manually at any point in your code using: Copy NetworkManager.Instance().StartNetwork(); This will initialize the network using the selected **Connection Mode** from the `NetworkManager`. * * * ### [](https://onlineobject.gitbook.io/objectnet/general/networkmanager-functions/starting-and-stopping-network#manual-mode-runtime-configuration) \- Manual Mode (Runtime Configuration) For full control, you can use **Manual Mode**, which allows you to decide at runtime whether to act as a server or client. This is useful for letting players choose how they want to connect.![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2F3009462755-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FNG75ky1pR1kRokWLRnzy%252Fuploads%252FINPQ75BBwL4BoRWNpWDe%252Fimage.png%3Falt%3Dmedia%26token%3D46fdde28-dce4-4a28-a81c-9193abe779b4&width=300&dpr=4&quality=100&sign=212baee5&sv=2) Copy string ipAddress = NetworkManager.Instance().GetPrivateIp(); // Configure the network manager to operate in server mode. NetworkManager.Instance().ConfigureMode(NetworkConnectionType.Server); NetworkManager.Instance().SetServerAddress(ipAddress); NetworkManager.Instance().StartNetwork(); Copy //let the client input the server ip manually, for example through a UI input field string serverIpAdress = inputfield.text; // Configure the network manager to operate in client mode. NetworkManager.Instance().ConfigureMode(NetworkConnectionType.Client); NetworkManager.Instance().SetServerAddress(serverIpAdress); NetworkManager.Instance().StartNetwork(); * * * [](https://onlineobject.gitbook.io/objectnet/general/networkmanager-functions/starting-and-stopping-network#stopping-the-network) Stopping the Network: ------------------------------------------------------------------------------------------------------------------------------------------------------------ To gracefully stop an active network session, call: Copy NetworkManager.Instance().StopNetwork(); //Note:For steam transport use this instead //(this will both stop the network and leave the steam lobby) NetworkSteamManager.Instance().LeaveLobby(); * If called by the **server or host**, it will **disconnect all clients** and shut down the entire session. * If called by a **client**, it will **only disconnect that client** from the server without affecting others. * * * After stopping the network, it is recommended (but optional) to **destroy the NetworkManager** instance, especially if you plan to reload scenes or restart the session. This ensures all network-related values are reset cleanly. example: Copy NetworkManager.Instance().StopNetwork(); Destroy(NetworkManager.Instance().gameObject); SceneManager.LoadScene("MainMenuScene"); After disconnecting, you must use Unity's `SceneManager` to load a clean menu or lobby scene. `NetworkManager.LoadSceneRemote()` is **only available while a network connection is active** and cannot be used after disconnection. [PreviousNetworkManager Functions](https://onlineobject.gitbook.io/objectnet/general/networkmanager-functions) [NextScene Managment](https://onlineobject.gitbook.io/objectnet/general/networkmanager-functions/scene-managment) Last updated 5 months ago --- # Importing Examples | ObjectNet ObjectNet provides many example scenes, importing "Examples Scenes \[ URP \]" extra package will import all 28 ObjectNet examples to be used as reference guide. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem227.png&width=768&dpr=4&quality=100&sign=7b66bb0c&sv=2) ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fcontent.gitbook.com%2Fcontent%2FNG75ky1pR1kRokWLRnzy%2Fblobs%2FLtHYzN0aJ3KQicweFR0J%2Fimage.png&width=768&dpr=4&quality=100&sign=5eaf172f&sv=2) [](https://onlineobject.gitbook.io/objectnet/general/example-scenes/importing-examples#add-on-example-scenes) Add-On Example Scenes: ----------------------------------------------------------------------------------------------------------------------------------------- Add-On Example scenes can be imported the same way, importing "Examples Scenes \[ Add-Ons \]" extra package will import both, Steam and Dissonance example scenes to be used as reference guide. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2F3009462755-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FNG75ky1pR1kRokWLRnzy%252Fuploads%252FeJsLnUctr8dCkTY7CQvF%252FScreenshot%25202025-04-17%2520223926.png%3Falt%3Dmedia%26token%3Dc2f4077f-2c98-4d21-86d8-aa4aa362cc9f&width=768&dpr=4&quality=100&sign=16a48ebe&sv=2) ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2F3009462755-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FNG75ky1pR1kRokWLRnzy%252Fuploads%252FkZ72I0LET9oQUqzxIPJl%252Fimage.png%3Falt%3Dmedia%26token%3D5e3b3c36-6d58-47d7-bac1-51e8000368bd&width=768&dpr=4&quality=100&sign=83c9dd2c&sv=2) [PreviousExample Scenes](https://onlineobject.gitbook.io/objectnet/general/example-scenes) [NextConverting Materials](https://onlineobject.gitbook.io/objectnet/general/example-scenes/converting-materials) Last updated 7 months ago --- # Converting Materials | ObjectNet ObjectNet provides many example scenes using URP as the default Render Pipeline, nonetheless, you may be using another pipeline, this section explains how to change materials to be correctly rendered. The following steps explain how to convert materials manually, to see how to do this automatically check the end of this section. 1. On project explorer click on "Search by type" option and select Material option. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem215.png&width=768&dpr=4&quality=100&sign=abb6b483&sv=2) 1. This shall list all materials on your project ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem216.png&width=300&dpr=4&quality=100&sign=285fc664&sv=2) 1. Select materials on the Examples folder of ObjectNet. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem219.png&width=300&dpr=4&quality=100&sign=84163647&sv=2) 1. On the inspector an error must be displayed showing InternalErrorShader ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem217.png&width=300&dpr=4&quality=100&sign=1b5cbf29&sv=2) 1. Click on combo box and select Standard shader option ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem220.png&width=300&dpr=4&quality=100&sign=a2e38c07&sv=2) 1. Do this for all materials with same error and all scenes shall be correctly rendered ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem221.png&width=768&dpr=4&quality=100&sign=ac4c277a&sv=2) ObjectsNet provide an extra package with all materials into build in format, importing this package will convert all materials used by object net examples into build in format. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem226.png&width=768&dpr=4&quality=100&sign=9249ceb1&sv=2) [PreviousImporting Examples](https://onlineobject.gitbook.io/objectnet/general/example-scenes/importing-examples) [NextRelay Example](https://onlineobject.gitbook.io/objectnet/general/example-scenes/relay-example) --- # Relay Example | ObjectNet ObjectNet allows to use game architecture on Relay mode ( see [Relay Mode](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/server-mode#relay-mode) ). [PreviousConverting Materials](https://onlineobject.gitbook.io/objectnet/general/example-scenes/converting-materials) [NextBuilding Server](https://onlineobject.gitbook.io/objectnet/general/example-scenes/relay-example/building-server) --- # Common Functions | ObjectNet Here are some Common fuctions that NetworkManager provides that you may find usful. IsRunningLogic()[](https://onlineobject.gitbook.io/objectnet/general/networkmanager-functions/common-functions#isrunninglogic) This checks if your current device is the **host** — the one responsible for running all the **authoritative game logic**. * In both normal and relay modes, it returns `true` only for the actual gameplay host (not the relay server). * This is what you should use when deciding who runs logic like health updates, object spawning, etc. > Think of this as: _"Am I in charge of running the game world?"_ Copy NetworkManager.Instance().IsRunningLogic() IsServerConnection()[](https://onlineobject.gitbook.io/objectnet/general/networkmanager-functions/common-functions#isserverconnection) This checks if your current connection is the **server** (the one routing messages). * In a **relay setup**, this will return `true` for the relay server — even though it's not running game logic. * In Embedded and Authoritative server, this also returns `true` for the headless instance. > Think of this as: _"Am I the connection point for others?"_ Copy NetworkManager.Instance().IsServerConnection(); GetConnectionID()[](https://onlineobject.gitbook.io/objectnet/general/networkmanager-functions/common-functions#getconnectionid) Each Clients that join the session has a unique Connection ID used to distinguish between clients you can get that using. Copy NetworkManager.Instance().GetConnection().GetSocket().GetConnectionID(); You can do the same if you have the IClient of the client Copy //where client is an IClient (client as NetworkClient).GetConnectionId(); DisableAutoLoadSceneElements()[](https://onlineobject.gitbook.io/objectnet/general/networkmanager-functions/common-functions#disableautoloadsceneelements) ObjectNet AutoMatically detects elements that are existing on the scene and send them to the newlly joinned client. However you can disable this process and do it manually using Copy //Disable the AutoLoad Scene elements system NetworkManager.Instance().DisableAutoLoadSceneElements(); //Enable the AutoLoad scene elements system NetworkManager.Instance().EnableAutoLoadSceneElements(); //request the scene elements from the server NetworkManager.Instance().RequestRemoteSceneElements(); GetLocalPlayerObject()[](https://onlineobject.gitbook.io/objectnet/general/networkmanager-functions/common-functions#getlocalplayerobject) You can get the Local Player gameObject using Copy NetworkManager.Instance().GetLocalPlayerObject(); Get any Network Object[](https://onlineobject.gitbook.io/objectnet/general/networkmanager-functions/common-functions#get-any-network-object) you can get the refrence of any Network Object in the scene using its NetworkID Copy //Get the GameObject of any Network object using the Network id GameObject instance = NetworkManager.Container.GetElement(NetworkId).GetGameObject(); GetActiveTransport()[](https://onlineobject.gitbook.io/objectnet/general/networkmanager-functions/common-functions#getactivetransport) You can get the currently used NetworkTransport name using Copy NetworkManager.Instance().GetActiveTransport().GetName(); Kick players[](https://onlineobject.gitbook.io/objectnet/general/networkmanager-functions/common-functions#kick-players) you can kick any player if you have their IClient just like the example below Copy client.GetTransport().Disconnect() Here is an example that will kick all players except for the host Copy IClient[] clients = NetworkManager.Instance().GetConnectedClients(); foreach (IClient client in clients) { client.GetTransport().Disconnect(); } For a complete list, refer to the [API Documentation](https://onlineobject.net/objectnet/docs/api/html/N-com.onlineobject.objectnet.htm) . [PreviousSending Global Events](https://onlineobject.gitbook.io/objectnet/general/networkmanager-functions/sending-global-events) [NextExample Scenes](https://onlineobject.gitbook.io/objectnet/general/example-scenes) Last updated 6 months ago --- # Example Scenes | ObjectNet ObjectNet provides a bunch of examples of scenes to be used as guidelines. You can use those scenes only as guidelines or as a multiplayer project's starting point. Each scene was created to explain one aspect of ObjectNet, nonetheless, some scenes can cover more than one feature. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem222.png&width=768&dpr=4&quality=100&sign=b6ee0fed&sv=2) * * * Note: If examples scenes appear in punk color you need to convert your materials (see [Converting Materials](https://onlineobject.gitbook.io/objectnet/general/example-scenes/converting-materials) ). ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem214.png&width=768&dpr=4&quality=100&sign=b8150296&sv=2) [PreviousCommon Functions](https://onlineobject.gitbook.io/objectnet/general/networkmanager-functions/common-functions) [NextImporting Examples](https://onlineobject.gitbook.io/objectnet/general/example-scenes/importing-examples) --- # Manual Scene Load | ObjectNet ObjectNet supports **multi-scene networking**, allowing each player to load and manage scenes independently. This gives you powerful flexibility in designing seamless multiplayer experiences — from lobbies and separate instances to dynamic world streaming. * * * [](https://onlineobject.gitbook.io/objectnet/general/networkmanager-functions/scene-managment/manual-scene-load#players-in-different-scenes) Players in Different Scenes ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Players can be in **different scenes at the same time** (e.g., Player A in "Scene 1", Player B in "Scene 2"). However, networked player objects still **exist across all scenes**, meaning: * Each player’s GameObject will still be instantiated on all clients * You are responsible for **hiding, disabling, or ignoring** remote players who are in other scenes > This enables scene isolation while keeping network presence consistent. * * * [](https://onlineobject.gitbook.io/objectnet/general/networkmanager-functions/scene-managment/manual-scene-load#loading-scenes-manually) Loading Scenes Manually --------------------------------------------------------------------------------------------------------------------------------------------------------------------- You can use Unity's built-in scene management to load scenes manually: Copy SceneManager.LoadScene("SceneName", LoadSceneMode.Single); Each client can load scenes independently using standard Unity logic. ObjectNet does **not restrict or force scene sync**, which is ideal for custom transitions, lobbies, or instancing. * * * [](https://onlineobject.gitbook.io/objectnet/general/networkmanager-functions/scene-managment/manual-scene-load#handling-large-scene-loads) Handling Large Scene Loads --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Loading large scenes may cause frame drops or temporarily **freeze the main thread**, which can lead to **false disconnection detection**. To prevent this during loading: #### [](https://onlineobject.gitbook.io/objectnet/general/networkmanager-functions/scene-managment/manual-scene-load#pause-disconnection-detection-server-side) 🛑 Pause Disconnection Detection (Server-side) Copy NetworkManager.Instance().PauseDisconnectDetection(true); Call this before starting a scene load. It prevents ObjectNet from thinking the client disconnected. #### [](https://onlineobject.gitbook.io/objectnet/general/networkmanager-functions/scene-managment/manual-scene-load#resume-detection-after-load-server-side) ▶️ Resume Detection After Load (Server-side) Copy NetworkManager.Instance().ResumeDisconnectDetection(); Call this once the scene is fully loaded and ready. **Important:** Forgetting to resume detection will prevent ObjectNet from detecting actual disconnects later. Pausing disconnection detection is a **double-edged sword**. While it helps prevent false disconnects during heavy operations like scene loading, it also **disables ObjectNet’s ability to detect real disconnections**. Always make sure to call `ResumeDisconnectDetection()` immediately after the operation is complete. Failing to resume detection can leave your application unaware of dropped clients. * * * [](https://onlineobject.gitbook.io/objectnet/general/networkmanager-functions/scene-managment/manual-scene-load#controlling-scene-element-instantiation) Controlling Scene Element Instantiation ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- By default, ObjectNet **automatically spawns all relevant networked elements** into every scene — even if the player isn't in that scene. You can override this behavior to prevent unwanted elements from being instantiated. #### [](https://onlineobject.gitbook.io/objectnet/general/networkmanager-functions/scene-managment/manual-scene-load#disable-automatic-scene-elements-client-side) ❌ Disable Automatic Scene Elements (Client-side) Copy NetworkManager.Instance().DisableAutoLoadSceneElements(); * Prevents automatic instantiation of remote scene objects * Useful for scenes like lobbies or menus, where you don’t want in-game elements loaded #### [](https://onlineobject.gitbook.io/objectnet/general/networkmanager-functions/scene-managment/manual-scene-load#enable-auto-scene-elements-client-side) ✅ Enable Auto Scene Elements (Client-side) Copy NetworkManager.Instance().EnableAutoLoadSceneElements(); * Re-enables auto instantiation * Use this **after** the new scene is fully loaded Note: Enabling **Auto Load Scene Elements** does **not automatically spawn existing scene elements**. You must manually request them by calling `RequestRemoteSceneElements()`. See the section below for details. * * * [](https://onlineobject.gitbook.io/objectnet/general/networkmanager-functions/scene-managment/manual-scene-load#requesting-scene-elements-on-demand) Requesting Scene Elements On Demand --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Even if auto-loading is disabled, you can **manually request** all missing scene elements: Copy NetworkManager.Instance().RequestRemoteSceneElements(); This will: * Check what scene objects are missing * Spawn only the relevant ones on the current client * **Avoid duplication or overload** [PreviousScene Managment](https://onlineobject.gitbook.io/objectnet/general/networkmanager-functions/scene-managment) [NextSending Global Events](https://onlineobject.gitbook.io/objectnet/general/networkmanager-functions/sending-global-events) Last updated 7 months ago --- # Third Party Assets | ObjectNet [Dissonance Voice Chat](https://onlineobject.gitbook.io/objectnet/extras/third-party-assets/dissonance-voice-chat) [SmoothSync](https://onlineobject.gitbook.io/objectnet/extras/third-party-assets/smoothsync) [PreviousCustom Behaviour](https://onlineobject.gitbook.io/objectnet/advance/custom-behaviour) [NextDissonance Voice Chat](https://onlineobject.gitbook.io/objectnet/extras/third-party-assets/dissonance-voice-chat) --- # Docker | ObjectNet [PreviousSteam Transport](https://onlineobject.gitbook.io/objectnet/extras/steam-transport) --- # Dissonance Voice Chat | ObjectNet [Dissonance](https://assetstore.unity.com/packages/tools/audio/dissonance-voice-chat-70078) is a premium third-party Unity asset designed for implementing **real-time voice chat** in multiplayer games. It is widely used and trusted for its low latency, high performance, and ease of integration. If you're planning to add voice communication to your project, we **highly recommend Dissonance** as the go-to solution. It supports features like: * Positional audio * Voice prioritization * Channel-based communication * Seamless integration with various networking frameworks [](https://onlineobject.gitbook.io/objectnet/extras/third-party-assets/dissonance-voice-chat#dissonance-integration) Dissonance Integration ------------------------------------------------------------------------------------------------------------------------------------------------ ObjectNet provides **built-in support** for Dissonance, making integration fast and straightforward. With just a few setup steps, you can enable synchronized voice chat across all players in your networked game. > 📺 **Watch this tutorial video** to learn how to integrate Dissonance with ObjectNet step-by-step: 📚 For more detailed usage instructions, **refer to the official** [**Dissonance documentation**](https://placeholder-software.co.uk/dissonance/docs/index.html) to understand how to configure voice rooms, control transmit behavior, and access advanced features. [PreviousThird Party Assets](https://onlineobject.gitbook.io/objectnet/extras/third-party-assets) [NextSmoothSync](https://onlineobject.gitbook.io/objectnet/extras/third-party-assets/smoothsync) Last updated 7 months ago --- # Lobby Example | ObjectNet ObjectNet allows to use game architecture on Relay mode allowing player to create and enter on Lobbies [PreviousBuilding Client](https://onlineobject.gitbook.io/objectnet/general/example-scenes/relay-example/building-client) [NextBuilding Server](https://onlineobject.gitbook.io/objectnet/general/example-scenes/lobby-example/building-server) --- # Authoritative Example | ObjectNet ObjectNet allows to use game architecture on Authoritative mode ( see [Authoritative Mode](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/server-mode#authoritative-mode) ). [PreviousBuilding Client](https://onlineobject.gitbook.io/objectnet/general/example-scenes/lobby-example/building-client) [NextBuilding Server](https://onlineobject.gitbook.io/objectnet/general/example-scenes/authoritative-example/building-server) --- # Building Server | ObjectNet Open scene "20 - Relay" under examples scene folder. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem165.png&width=768&dpr=4&quality=100&sign=f449cde1&sv=2) Ensure that following option if correctly, if not, change it. 1. Server mode is in Relay mode. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem166.png&width=768&dpr=4&quality=100&sign=2be244ae&sv=2) 1. "Enable Lobby support" in unchecked ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem167.png&width=768&dpr=4&quality=100&sign=8fe26c3b&sv=2) 1. Server connection type shall be selected ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem168.png&width=768&dpr=4&quality=100&sign=5a1a28f0&sv=2) 1. "Connect on Start" is checked ( This will ensure that server will start after launched ) ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem169.png&width=300&dpr=4&quality=100&sign=dfa7bb95&sv=2) 1. Now you need to switch you project to "Dedicated Server Mode" ( see [Unity Dedicated Server](https://onlineobject.net/objectnet/docs/manual/UnityDedicatedServer.html) ) ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem170.png&width=300&dpr=4&quality=100&sign=5877fe0b&sv=2) 1. After finished a "Build" option shall appear ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem171.png&width=300&dpr=4&quality=100&sign=eac94efe&sv=2) 1. Build server mode into a separated folder ( It's important separate Game build from Server build ) ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem172.png&width=768&dpr=4&quality=100&sign=3e4e6071&sv=2) 1. No run the server build ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem174.png&width=768&dpr=4&quality=100&sign=752dbac7&sv=2) 1. Server should be run without any problem ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem175.png&width=768&dpr=4&quality=100&sign=bac2ed3a&sv=2) The log shall show the server up and running and the current user transport system. [PreviousRelay Example](https://onlineobject.gitbook.io/objectnet/general/example-scenes/relay-example) [NextBuilding Client](https://onlineobject.gitbook.io/objectnet/general/example-scenes/relay-example/building-client) --- # Custom DataStream | ObjectNet ObjectNet provides the facility to send and receive simple and complex structured over-network ( see [DataStream](https://onlineobject.gitbook.io/objectnet/general/fundamentals/datastream) ). In multiplayer games, you often need to send custom data over the network—like a player’s stats, a damage hit, or a full status effect. Instead of sending each field manually every time, Custom DataStream (**serialization)** lets you group that data into a class and send it with a single line. ObjectNet makes this easy with **custom DataStreams**. * * * [](https://onlineobject.gitbook.io/objectnet/advance/custom-datastream#why-use-custom-datastream) Why Use Custom DataStream? --------------------------------------------------------------------------------------------------------------------------------- Let’s say you have a `Damage` class with two values: Copy public class Damage { public int amount; public Vector3 direction; //constroctor public Damage(int amount, Vector3 direction) { this.amount = amount; this.direction = direction; } } Without serialization, you’d need to write each value manually every time: Copy writer.Write(damage.amount); writer.Write(damage.direction); That’s repetitive and error-prone. Instead: Serialize Once, Reuse Everywhere With a custom DataStream, you can send the full object like this: Copy writer.Write(damage); And read it just as easily: Copy Damage damage = reader.Read(); * * * [](https://onlineobject.gitbook.io/objectnet/advance/custom-datastream#how-to-create-a-custom-datastream) How to Create a Custom DataStream ------------------------------------------------------------------------------------------------------------------------------------------------ ### [](https://onlineobject.gitbook.io/objectnet/advance/custom-datastream#id-1.-create-the-data-handler) 1\. Create the Data Handler To teach ObjectNet how to read/write your class, create a new class that inherits from `DataHandler`: Copy public class DamageStream : DataHandler { public override int Write(Damage data, ref byte[] buffer, ref int offset) { int result = base.Write(data.amount, ref buffer, ref offset, typeof(int)); result += base.Write(data.direction, ref buffer, ref offset, typeof(Vector3)); return result; } public override Damage Read(byte[] buffer, ref int offset) { int amount = Read(buffer, ref offset); Vector3 dir = Read(buffer, ref offset); return new Damage(amount, dir); } } The order of reading must exactly match the order of writing. * * * ### [](https://onlineobject.gitbook.io/objectnet/advance/custom-datastream#id-2.-register-your-stream) 2\. Register Your Stream Register your handler once (e.g. at startup): Copy DataStream.RegisterGlobalStream(); This tells ObjectNet: > “Whenever I send or receive a `Damage` object, use the `DamageStream` class to handle it.” [PreviousBuilding Client](https://onlineobject.gitbook.io/objectnet/general/example-scenes/authoritative-example/building-client) [NextCustom Behaviour](https://onlineobject.gitbook.io/objectnet/advance/custom-behaviour) Last updated 6 months ago --- # Building Server | ObjectNet Open scene "21 - Lobby" under examples scene folder. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem185.png&width=768&dpr=4&quality=100&sign=b67e1613&sv=2) Ensure that following option if correctly, if not, change it. 1. Server mode is in Relay mode. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem166.png&width=768&dpr=4&quality=100&sign=2be244ae&sv=2) 1. "Enable Lobby support" in checked ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem186.png&width=768&dpr=4&quality=100&sign=44ae88f4&sv=2) 1. Server connection type shall be selected ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem168.png&width=768&dpr=4&quality=100&sign=5a1a28f0&sv=2) 1. "Connect on Start" is checked ( This will ensure that server will start after launched ) ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem169.png&width=300&dpr=4&quality=100&sign=dfa7bb95&sv=2) 1. Now you need to switch you project to "Dedicated Server Mode" ( see [Unity Dedicated Server](https://onlineobject.gitbook.io/objectnet/extras/unity-dedicated-server) ) ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem170.png&width=300&dpr=4&quality=100&sign=5877fe0b&sv=2) 1. After finished a "Build" option shall appear ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem171.png&width=300&dpr=4&quality=100&sign=eac94efe&sv=2) 1. Build server mode into a separated folder ( It's important separate Game build from Server build ) ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem172.png&width=768&dpr=4&quality=100&sign=3e4e6071&sv=2) 1. No run the server build ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem174.png&width=768&dpr=4&quality=100&sign=752dbac7&sv=2) 1. Server should be run without any problem ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem175.png&width=768&dpr=4&quality=100&sign=bac2ed3a&sv=2) The log shall show the server up and running and the current user transport system. [PreviousLobby Example](https://onlineobject.gitbook.io/objectnet/general/example-scenes/lobby-example) [NextBuilding Client](https://onlineobject.gitbook.io/objectnet/general/example-scenes/lobby-example/building-client) --- # Unity Transport | ObjectNet ObjectNet allow to use Unity Transport System as in use transport system. 1. Open the Unity Package Manager by navigating to Window > Package Manager along the top bar. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem197.png&width=768&dpr=4&quality=100&sign=624256b6&sv=2) 1. Click Add in the status bar. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem198.png&width=768&dpr=4&quality=100&sign=1fd4d64d&sv=2) 1. Find "Unity Transport Package" ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem199.png&width=300&dpr=4&quality=100&sign=16003e88&sv=2) 1. Click to install package. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem200.png&width=768&dpr=4&quality=100&sign=a53a12b5&sv=2) Is this options not appear see official Unity documentation ( see [Installing Unity Transport System](https://docs.unity3d.com/Packages/com.unity.transport@2.0/manual/install.html) ). [PreviousUnity Dedicated Server](https://onlineobject.gitbook.io/objectnet/extras/unity-dedicated-server) [NextSteam Transport](https://onlineobject.gitbook.io/objectnet/extras/steam-transport) --- # Building Client | ObjectNet Open scene "21 - Lobby" under examples scene folder. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem165.png&width=768&dpr=4&quality=100&sign=f449cde1&sv=2) Ensure that following option if correctly, if not, change it. 1. "Embedded" or "Client Only" must be selected. On this example we will select "Embedded". ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem176.png&width=768&dpr=4&quality=100&sign=9fc28bad&sv=2) 1. "Enable Lobby support" in unchecked ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem167.png&width=768&dpr=4&quality=100&sign=8fe26c3b&sv=2) 1. "Client" or "Manual" connection type shall be flagged ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem177.png&width=768&dpr=4&quality=100&sign=feca6368&sv=2) 1. Now you need to switch you project to the selected platform target, on this case we going to use "Windows, Mac, Linux" ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem178.png&width=300&dpr=4&quality=100&sign=9cce3903&sv=2) 1. After finished a "Build" option shall appear ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem179.png&width=300&dpr=4&quality=100&sign=a92c8716&sv=2) 1. Build server mode into a separated folder ( It's important separate Game build from Server build ) ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem180.png&width=768&dpr=4&quality=100&sign=73c23362&sv=2) 1. No run the compiled game ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem174.png&width=768&dpr=4&quality=100&sign=752dbac7&sv=2) 1. The game shall start ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem181.png&width=300&dpr=4&quality=100&sign=f2329f6f&sv=2) 1. A window shall appear to allow to create or enter into a lobby ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem187.png&width=300&dpr=4&quality=100&sign=bf26ca79&sv=2) ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem188.png&width=300&dpr=4&quality=100&sign=2f526d4a&sv=2) 1. If you wish to list current lobbies, you need to click on "Refresh Lobbies" and then click into join on the selected lobby ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem189.png&width=300&dpr=4&quality=100&sign=439fd557&sv=2) 1. Player must be spawned on scene ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem182.png&width=300&dpr=4&quality=100&sign=1fb68810&sv=2) 1. Player will be connected at Server ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem184.png&width=768&dpr=4&quality=100&sign=51d7d666&sv=2) [PreviousBuilding Server](https://onlineobject.gitbook.io/objectnet/general/example-scenes/lobby-example/building-server) [NextAuthoritative Example](https://onlineobject.gitbook.io/objectnet/general/example-scenes/authoritative-example) --- # Sending Global Events | ObjectNet ObjectNet provides a full API to allow the developer to send and listen to events by code. That event can be global or local. Global Events can be listened to or sent by any part of your code, on the other hand, Local Events can only be sent or caught by the object who sends and listens to this event. This section will cover Global Event, the Object Event is covered on [Sending Events](https://onlineobject.gitbook.io/objectnet/general/network-behaviour/sending-events) section. [](https://onlineobject.gitbook.io/objectnet/general/networkmanager-functions/sending-global-events#sending) Sending ------------------------------------------------------------------------------------------------------------------------- This section covers how to send events over the network. First, you need to create a unique identifier for this event, this identifier shall be a positive integer number. Copy const int CUSTOM_EVENT = 10000; Note: It's highly recommenced to group events to avoid two events using the same code. Events provide the possibility to send data, for example, in an event to restart a player position you may wish to send position information in the message. ObjectNet allows us to do this by using DataWritter. This code illustrates how to send an event over the network, you can include data on the message to be received at the target destination. Copy using (DataStream writer = new DataStream()) { writer.Write(this.targetPosition); // Vector3 writer.Write(this.remaingLife); // float writer.Write(this.money); // int // Send event using the NetworkManager NetworkManager.Instance().Send(CUSTOM_EVENT, writer, DeliveryMode.Reliable); } [](https://onlineobject.gitbook.io/objectnet/general/networkmanager-functions/sending-global-events#listening) Listening ----------------------------------------------------------------------------------------------------------------------------- You can listen to events sent by other network peers and execute some action based on this event, this process is called by ObjectNet a Listener on an event. This code illustrates how to listen to some network events, read data on these events, and take some action. Copy public void Start() { NetworkManager.RegisterEvent(CUSTOM_EVENT, this.OnCustomEventReceived); } private void OnCustomEventReceived(IDataStream reader) { Vector3 receivedTargetPosition = reader.Read(); float remaningLife = reader.Read(); int money = reader.Read(); // Update player with received information this.UpdatePlayer(receivedPosition, remaningLife, money); } On this piece of code, the CUSTOM\_EVENT is registered to execute "OnCustomEventReceived" arrives. The code of OnCustomEventReceived the first extract parameter in the same order that was sent. With this information, some method must be called to update an object, change status, create or destroy items, and another code to make your multiplayer game work. Note: "OnCustomEventReceived" will **not be triggered on the sender**. Events are broadcast **to other clients**, not to the sender itself. You will need to execute \`this.UpdatePlayer()\` manually if thats what you want. Global Events only accepts one Method to be subscribed to one event code at a time. Full Code Example[](https://onlineobject.gitbook.io/objectnet/general/networkmanager-functions/sending-global-events#full-code-example) Copy using UnityEngine; using com.onlineobject.objectnet; public class SendGlobalEventExample : MonoBehaviour { const int CUSTOM_EVENT = 10000; //Subscribe the reciever method to the event public void Start() { NetworkManager.RegisterEvent(CUSTOM_EVENT, this.OnCustomEventReceived); } private void Update(){ //makes sure only the active running this code if (IsPassive()) return; // sends the event when ever the user press T if (Input.GetKeyDown(KeyCode.T)){ using (DataStream writer = new DataStream()) { writer.Write(this.targetPosition); // Vector3 writer.Write(this.remaingLife); // float writer.Write(this.money); // int // Send event NetworkManager.Instance().Send(CUSTOM_EVENT, writer, DeliveryMode.Reliable); } } } //Event will trigger this method private void OnCustomEventReceived(IDataStream reader) { Vector3 receivedTargetPosition = reader.Read(); float remaningLife = reader.Read(); int money = reader.Read(); // Update player with received information this.UpdatePlayer(receivedPosition, remaningLife, money); } //regular method private void UpdatePlayer(Vector3 position, float remaingLife, int money){ //any logic } } Replace[](https://onlineobject.gitbook.io/objectnet/general/networkmanager-functions/sending-global-events#replace) Global Events only accepts one Method to be subscribed to one event code at a time. So make sure if the object is destroyed and respawned to set Replace parameter to true. (for examle when scene is restarted). ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fcontent.gitbook.com%2Fcontent%2FNG75ky1pR1kRokWLRnzy%2Fblobs%2FNtWyPISTFnjmflOsfejP%2FScreenshot%25202025-04-17%2520132720%2520-%25202.png&width=768&dpr=4&quality=100&sign=c8ae0136&sv=2) BroadCast[](https://onlineobject.gitbook.io/objectnet/general/networkmanager-functions/sending-global-events#broadcast) When registering the event you have an option to broadcast the event to other clients. other wise the event will only be triggered on the server. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fcontent.gitbook.com%2Fcontent%2FNG75ky1pR1kRokWLRnzy%2Fblobs%2F1erchlspx0gsKi8IX3MT%2FScreenshot%25202025-04-17%2520132720.png&width=768&dpr=4&quality=100&sign=9eaa14a&sv=2) This tells the server to propagate the message coming from one client to all other clients. Note: if the sender is the Server then all clients will recive the message regardless if broadcast was true or false, broadcast option is only for clients that want to communicate with other clients. Supported Data Types[](https://onlineobject.gitbook.io/objectnet/general/networkmanager-functions/sending-global-events#supported-data-types) You can include the following data types on the event message. Copy int uint long ulong short ushort float double ------------------------------------------------------------- byte sbyte byte[] bool string char char[] enum ------------------------------------------------------------- Vector2 Vector3 Vector4 Quaternion Color Matrix4x4 * * * [](https://onlineobject.gitbook.io/objectnet/general/networkmanager-functions/sending-global-events#faq) FAQ: ------------------------------------------------------------------------------------------------------------------ Show me an Example on how to send a list using DataStream[](https://onlineobject.gitbook.io/objectnet/general/networkmanager-functions/sending-global-events#show-me-an-example-on-how-to-send-a-list-using-datastream) Here is an example that illustrate the write and read of a full list. Copy private List Numbers = new List(); //any where in you script using (DataStream writer = new DataStream()){ //write the length of the list writer.Write(this.Numbers.Count); // int //write each value on the list for (int i = 0; i < Numbers.Count; i++){ writer.Write(Numbers[i]); } // Send event NetworkManager.Instance().Send(LOCAL_CUSTOM_EVENT, writer, DeliveryMode.Reliable); } //On the reciver private void OnCustomEventReceivedOnObject(IDataStream reader){ //read the length int listLength = reader.Read(); //read and update each value on the list for (int i = 0; i < listLength; i++){ Numbers[i] = reader.Read(); } } Why the Event is not triggered on the sender?[](https://onlineobject.gitbook.io/objectnet/general/networkmanager-functions/sending-global-events#why-the-event-is-not-triggered-on-the-sender) Events will **not be triggered on the sender**. Custom events are broadcast **to other clients**, not to the sender itself. When a client sends a `DataStream` message, the message is **not looped back to the sender**. This means the sender will **not receive or trigger the event locally**. If you want the sender to also process the logic, you’ll need to **manually invoke the logic** on the sender’s side after sending. Copy //for example using (DataStream writer = new DataStream()) { writer.Write(this.targetPosition); // Vector3 writer.Write(this.remaingLife); // float writer.Write(this.money); // int // Send event NetworkManager.Instance().Send(CUSTOM_EVENT, writer, DeliveryMode.Reliable); } //execute locally this.UpdatePlayer(this.targetPosition, this.remaingLife, this.money); [PreviousManual Scene Load](https://onlineobject.gitbook.io/objectnet/general/networkmanager-functions/scene-managment/manual-scene-load) [NextCommon Functions](https://onlineobject.gitbook.io/objectnet/general/networkmanager-functions/common-functions) Last updated 6 months ago --- # Building Client | ObjectNet Open scene "20 - Relay" under examples scene folder. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem165.png&width=768&dpr=4&quality=100&sign=f449cde1&sv=2) Ensure that following option if correctly, if not, change it. 1. "Embedded" or "Client Only" must be selected. On this example we will select "Embedded". ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem176.png&width=768&dpr=4&quality=100&sign=9fc28bad&sv=2) 1. "Enable Lobby support" in unchecked ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem167.png&width=768&dpr=4&quality=100&sign=8fe26c3b&sv=2) 1. "Client" or "Manual" connection type shall be flagged ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem177.png&width=768&dpr=4&quality=100&sign=feca6368&sv=2) 1. Now you need to switch you project to the selected platform target, on this case we going to use "Windows, Mac, Linux" ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem178.png&width=300&dpr=4&quality=100&sign=9cce3903&sv=2) 1. After finished a "Build" option shall appear ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem179.png&width=300&dpr=4&quality=100&sign=a92c8716&sv=2) 1. Build server mode into a separated folder ( It's important separate Game build from Server build ) ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem180.png&width=768&dpr=4&quality=100&sign=73c23362&sv=2) 1. No run the compiled game ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem174.png&width=768&dpr=4&quality=100&sign=752dbac7&sv=2) 1. The game shall start ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem181.png&width=300&dpr=4&quality=100&sign=f2329f6f&sv=2) 1. Player must be spawned on scene ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem182.png&width=300&dpr=4&quality=100&sign=1fb68810&sv=2) 1. Player will be connected at Server ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem184.png&width=768&dpr=4&quality=100&sign=51d7d666&sv=2) [PreviousBuilding Server](https://onlineobject.gitbook.io/objectnet/general/example-scenes/relay-example/building-server) [NextLobby Example](https://onlineobject.gitbook.io/objectnet/general/example-scenes/lobby-example) --- # Steam Transport | ObjectNet [](https://onlineobject.gitbook.io/objectnet/extras/steam-transport#faq) FAQ: ---------------------------------------------------------------------------------- Where can i find the Steam example scene[](https://onlineobject.gitbook.io/objectnet/extras/steam-transport#where-can-i-find-the-steam-example-scene) You can find it with the Add-on Example scenes check [Importing Examples](https://onlineobject.gitbook.io/objectnet/general/example-scenes/importing-examples) for more information on this topic. My steam build crashes after lunching it, what should i do?[](https://onlineobject.gitbook.io/objectnet/extras/steam-transport#my-steam-build-crashes-after-lunching-it-what-should-i-do) > **Note:** This issue may occur if you haven't included a `steam_appid.txt` file in your build directory. This file is required for Steam integration to work correctly during development and testing. If your game doesn’t have its own Steam App ID yet, you can use the default **test App ID** `**480**` (Steam's _Spacewar_ app) for testing purposes. Make sure the [steam\_appid.txt](https://kb.heathen.group/old-kb/steam/steam_appid.txt) file is placed in the **same folder as your game executable**, and that it contains your **Steam App ID** (or `480` for testing). I created a lobby, but my friend can't find it. What could be the reason?[](https://onlineobject.gitbook.io/objectnet/extras/steam-transport#i-created-a-lobby-but-my-friend-cant-find-it.-what-could-be-the-reason) If your friend is unable to see or join your Steam lobby, here are a few common causes to check: * * * **🌍 1. Lobby Distance Filter** Your friend might be located in a different region. Make sure the **lobby distance filter** is set to **“Worldwide”** in your Steam matchmaking settings. This ensures lobbies are visible across all geographical regions. * * * **🔓 2. Lobby Access Level** Check that the lobby’s **access level** is set to **“Public”**. Private or friends-only lobbies may not appear in the browser unless your friend meets the exact visibility criteria. * * * **🎮 3. Missing Game Ownership (Custom App ID)** If you're using a **custom Steam App ID** (such as your own game's App ID), your friend must own and have access to the same game through Steam. If they don’t have a valid copy, the lobby may not be visible or accessible to them. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2F3009462755-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FNG75ky1pR1kRokWLRnzy%252Fuploads%252FC1bM3r1punbJkTViv5jW%252FScreenshot%25202025-04-17%2520234740.png%3Falt%3Dmedia%26token%3Dd607dae9-b077-4bdc-a4b2-525f9181ad35&width=768&dpr=4&quality=100&sign=bf64bf64&sv=2) I got this Error : \[16:50:22\] (CLIENT): Invalid host address '7123518916342:4550'! IP and port should be separated by a colon, for example: '127.0.0.1:7777'.[](https://onlineobject.gitbook.io/objectnet/extras/steam-transport#i-got-this-error-16-50-22-client-invalid-host-address-7123518916342-4550-ip-and-port-should-be-separ) This is because you are using ObjectNet transport, while steam only works with SteamTransport, make sure you switch the transport on the NetworkManager when using steam. see [Network Transport](https://onlineobject.gitbook.io/objectnet/general/network-components/network-manager/network-transport) ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2F3009462755-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FNG75ky1pR1kRokWLRnzy%252Fuploads%252FarT5rRcyaAN37LUZuyyA%252Fimage.png%3Falt%3Dmedia%26token%3D1916467a-99c8-4347-b441-2498bf2f450b&width=768&dpr=4&quality=100&sign=bd1d05c0&sv=2) [PreviousUnity Transport](https://onlineobject.gitbook.io/objectnet/extras/unity-transport) [NextDocker](https://onlineobject.gitbook.io/objectnet/extras/docker) Last updated 6 months ago --- # Unity Dedicated Server | ObjectNet ObjectNet allow to create standalone build to run dedicated servers ( Relay and Authoritative ). Installing required modules To be able to build an standalone build of you game server you need to install Dedicated Server Build Support. 1. On Unity Hub select you unity install 2. On the right side gear select "Add modules" ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem195.png&width=300&dpr=4&quality=100&sign=22e8a604&sv=2) 1. Add Dedicated Server Build Support module ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem196.png&width=768&dpr=4&quality=100&sign=8f32f023&sv=2) Build your application for Dedicated Server You can create a Dedicated Server build through either of the following ways: 1. From the Unity Editor, select File > Build Settings. 2. Select Dedicated Server. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem194.png&width=768&dpr=4&quality=100&sign=866ad2c9&sv=2) [PreviousSmoothSync](https://onlineobject.gitbook.io/objectnet/extras/third-party-assets/smoothsync) [NextUnity Transport](https://onlineobject.gitbook.io/objectnet/extras/unity-transport) --- # Custom Behaviour | ObjectNet ObjectNet provides the facility to create custom behavior and apply it to NetworkObjects. To implement your own Behavior you can check the API document on NetworkEntity class. The following piece of code example of how to implement your behavior : Copy public struct DataToSync { public Vector3 positionValue; public Color color; } public class BehaviourExample : NetworkEntity { private DataToSync currentValue; public BehaviourExample() : base() { } public BehaviourExample(INetworkElement networkObject) : base(networkObject) { } public override void ComputeActive() { this.currentValue.positionValue = this.GetNetworkObject().GetGameObject().transform.position; this.currentValue.color = this.GetNetworkObject().GetGameObject().GetComponent().materials[0].color; } public override void ComputePassive() { this.GetNetworkObject().GetGameObject().transform.position = this.currentValue.positionValue; this.GetNetworkObject().GetGameObject().GetComponent().materials[0].color = this.currentValue.color; } public override DataToSync GetPassiveArguments() { return this.currentValue; } public override void SynchonizePassive(DataToSync data) { this.currentValue.color = data.color; this.currentValue.positionValue = data.positionValue; } public override void SynchonizeActive(IDataStream writer) { writer.Write(this.currentValue.positionValue); writer.Write(this.currentValue.color); } public override void Extract(IDataStream reader) { this.currentValue.positionValue = reader.Read(); this.currentValue.color = reader.Read(); } } After your behavior is created you need to register it on all objects that you need to synchronize information. Copy public void Awake() { this.GetNetworkElement().RegisterBehavior(new BehaviourExample()); } This code tells ObjectNet to include this behavior during the network synchronization procedure. [PreviousCustom DataStream](https://onlineobject.gitbook.io/objectnet/advance/custom-datastream) [NextThird Party Assets](https://onlineobject.gitbook.io/objectnet/extras/third-party-assets) --- # SmoothSync | ObjectNet [**Smooth Sync**](https://assetstore.unity.com/packages/tools/network/smooth-sync-96925) is a paid third-party Unity asset used to **synchronize object position, rotation, and scale** across the network with smooth interpolation and minimal jitter. It’s ideal for multiplayer games that require **precise and visually seamless object movement** — such as player characters, vehicles, or physics-based objects. Note: ObjectNet includes its own efficient [**Smooth Movement system**](https://www.youtube.com/watch?v=zJ6pjQN3TAc) for handling networked object motion. However, for developers who prefer an alternative solution, support for Smooth Sync is fully available and can be used in place of ObjectNet’s built-in synchronization. [](https://onlineobject.gitbook.io/objectnet/extras/third-party-assets/smoothsync#smooth-sync-integration) Smooth Sync Integration: ---------------------------------------------------------------------------------------------------------------------------------------- To use smooth sync with objectnet you need to first install the pack provided in our Discord channel "[Integration-Packs](https://discord.com/channels/1190264406907551824/1225147612701917294) ", this pack allows to use SmothSync with ObjectNet To use you need : 1. Disable all synchronizations of prefab into the Prefabs Database window 2. Add "SmoothSyncObjectNet" component to your prefab ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2F3009462755-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FNG75ky1pR1kRokWLRnzy%252Fuploads%252FsCIOBdgWfFND1tCRurWC%252Fsmoothsync%2520instructions.png%3Falt%3Dmedia%26token%3Dcba6d60b-8428-47af-b279-ee33ae23bb6f&width=768&dpr=4&quality=100&sign=3b0337f8&sv=2) ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2F3009462755-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FNG75ky1pR1kRokWLRnzy%252Fuploads%252FP2ZACL17sD2NVO8oIWka%252Fsmoothsync%2520component.png%3Falt%3Dmedia%26token%3D38c9469b-63f9-4b11-9b44-13152fb79300&width=768&dpr=4&quality=100&sign=950337c9&sv=2) Make sure the component is enabled on passive instances or else it will not work. 📚 For more detailed configuration and usage, be sure to refer to the [**official Smooth Sync documentation**](https://noblewhale.com/smooth_sync/) for advanced settings, optimization tips, and use-case examples. * * * [](https://onlineobject.gitbook.io/objectnet/extras/third-party-assets/smoothsync#faq) FAQ: ------------------------------------------------------------------------------------------------ I keep getting Event "-900090" is not regiestered[](https://onlineobject.gitbook.io/objectnet/extras/third-party-assets/smoothsync#i-keep-getting-event-900090-is-not-regiestered) This warning typically appears when a **Passive object has not finished initializing** before receiving data from its Active counterpart. This is expected behavior during early synchronization and will automatically resolve once the object is fully initialized. * * * #### [](https://onlineobject.gitbook.io/objectnet/extras/third-party-assets/smoothsync#still-seeing-the-warning-repeatedly) 🛠️ Still seeing the warning repeatedly? If the warning continues to appear after initialization, it's likely due to the **Smooth Sync component being disabled** on the Passive object. To fix this: 1. Open the **Prefab Database** in the `NetworkManager`. 2. Locate the prefab showing the issue. 3. Under the [**Script section**](https://onlineobject.gitbook.io/objectnet/general/network-components/network-prefabs/prefab-scripts) , **disable and re-enable** the Smooth Sync component. This will refresh the component registration and should resolve the warning. [PreviousDissonance Voice Chat](https://onlineobject.gitbook.io/objectnet/extras/third-party-assets/dissonance-voice-chat) [NextUnity Dedicated Server](https://onlineobject.gitbook.io/objectnet/extras/unity-dedicated-server) Last updated 7 months ago --- # Building Server | ObjectNet Open scene "22 - Authoritative" under examples scene folder. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem191.png&width=768&dpr=4&quality=100&sign=b74ff260&sv=2) Ensure that following option if correctly, if not, change it. 1. Server mode is in Authoritative mode. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem190.png&width=768&dpr=4&quality=100&sign=a1aa2ec5&sv=2) 1. Server connection type shall be selected ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem168.png&width=768&dpr=4&quality=100&sign=5a1a28f0&sv=2) 1. "Connect on Start" is checked ( This will ensure that server will start after launched ) ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem169.png&width=300&dpr=4&quality=100&sign=dfa7bb95&sv=2) 1. Now you need to switch you project to "Dedicated Server Mode" ( see [Unity Dedicated Server](https://onlineobject.gitbook.io/objectnet/extras/unity-dedicated-server) ) ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem170.png&width=300&dpr=4&quality=100&sign=5877fe0b&sv=2) 1. After finished a "Build" option shall appear ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem171.png&width=300&dpr=4&quality=100&sign=eac94efe&sv=2) 1. Build server mode into a separated folder ( It's important separate Game build from Server build ) ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem172.png&width=768&dpr=4&quality=100&sign=3e4e6071&sv=2) 1. No run the server build ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem174.png&width=768&dpr=4&quality=100&sign=752dbac7&sv=2) 1. Server should be run without any problem ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem175.png&width=768&dpr=4&quality=100&sign=bac2ed3a&sv=2) The log shall show the server up and running and the current user transport system. [PreviousAuthoritative Example](https://onlineobject.gitbook.io/objectnet/general/example-scenes/authoritative-example) [NextBuilding Client](https://onlineobject.gitbook.io/objectnet/general/example-scenes/authoritative-example/building-client) --- # Building Client | ObjectNet Open scene "22 - Authoritative" under examples scene folder. ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem192.png&width=768&dpr=4&quality=100&sign=7536d9bf&sv=2) Ensure that following option if correctly, if not, change it. 1. "Embedded" or "Client Only" must be selected. On this example we will select "Embedded". ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem176.png&width=768&dpr=4&quality=100&sign=9fc28bad&sv=2) 1. "Enable Lobby support" in unchecked ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem167.png&width=768&dpr=4&quality=100&sign=8fe26c3b&sv=2) 1. "Client" or "Manual" connection type shall be flagged ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem177.png&width=768&dpr=4&quality=100&sign=feca6368&sv=2) 1. Now you need to switch you project to the selected platform target, on this case we going to use "Windows, Mac, Linux" ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem178.png&width=300&dpr=4&quality=100&sign=9cce3903&sv=2) 1. After finished a "Build" option shall appear ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem179.png&width=300&dpr=4&quality=100&sign=a92c8716&sv=2) 1. Build server mode into a separated folder ( It's important separate Game build from Server build ) ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem180.png&width=768&dpr=4&quality=100&sign=73c23362&sv=2) 1. No run the compiled game ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem174.png&width=768&dpr=4&quality=100&sign=752dbac7&sv=2) 1. The game shall start ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem181.png&width=300&dpr=4&quality=100&sign=f2329f6f&sv=2) 1. A window shall appear to allow to create or enter into a lobby ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem187.png&width=300&dpr=4&quality=100&sign=bf26ca79&sv=2) ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem188.png&width=300&dpr=4&quality=100&sign=2f526d4a&sv=2) 1. If you wish to list current lobbies, you need to click on "Refresh Lobbies" and then click into join on the selected lobby ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem189.png&width=300&dpr=4&quality=100&sign=439fd557&sv=2) 1. Player must be spawned on scene ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem182.png&width=300&dpr=4&quality=100&sign=1fb68810&sv=2) 1. Player will be connected at Server ![](https://onlineobject.gitbook.io/objectnet/~gitbook/image?url=https%3A%2F%2Fonlineobject.net%2Fobjectnet%2Fdocs%2Fmanual%2Flib%2FNewItem184.png&width=768&dpr=4&quality=100&sign=51d7d666&sv=2) [PreviousBuilding Server](https://onlineobject.gitbook.io/objectnet/general/example-scenes/authoritative-example/building-server) [NextCustom DataStream](https://onlineobject.gitbook.io/objectnet/advance/custom-datastream) ---