# Managers and Important Scripts

### Managers

There should 2 main managers prefabs in your project. One Network Manager and one Game Manager.

The network manager is persistant (DontDestroyOnLoad) and should be in all your scenes including menu and game scenes. TheNetwork.cs is attached to this manager.

The game manager is NOT persistant and should only be in your game scenes. It contain NetworkGame.cs

#### TheNetwork.cs

Main networking script, it handles connecting clients to host, registering prefabs, and has basics functions to know if you’re on a server or client, and the ID of each client. This object is set to DontDestroyOnLoad so it persists between scenes. Use functions such as StartHost(), StartServer() and StartClient() to start a new connection.

#### NetworkGame.cs

Unlike TheNetwork, this one don’t persist between scenes. Should only be added to game scenes. It registers network messages specific to the gameplay. Handles spawning and despawning objects, and manages SNetworkVariable and SNetworkActions.&#x20;



### Lobby and Dedicated Server

#### ClientLobby.cs ServerLobby.cs

Managers for the client or server side of the lobby. Lobby uses Web Requests instead of connecting with Netcode. (WebTool.cs manages sending web requests). Which allow for a client to be connected to both the lobby and game at the same time.

#### ServerGame.cs

Main script for the dedicated server scene. It can receive command line parameters when started, such as the scene to load, game id and port. And it will start the game server based on parameters received.



### Components

#### SNetworkObject.cs

Add to all object prefabs that should be synced between server and clients, without it you can't use SNetworkBehavior, SNetworkActions and SNetworkVariable in your scripts. This script contains Spawn() and Despawn() functions to start/stop syncing an object, and it also holds a unique network\_id for each object in the scene.

#### SNetworkOptimizer.cs

Add this to any object to automatically spawn/despawn based on the distance of that object to players. Can be useful for optimization.

#### SNetworkPlayer.cs

Base script to add to your player character prefab. Is used by SNetworkOptimizer to know which objects should be active, it also holds the player\_id associated with that player. Can be inherited into your own custom script.&#x20;

