### NetworkManager Scene Setup Example Source: https://github.com/james-frowen/mirage.godot/blob/main/_autodocs/api-reference/network-manager.md Demonstrates how to instantiate and configure a NetworkManager node within a Godot scene, including setting up child nodes and network properties before starting a network mode. ```csharp // Create a NetworkManager node with child nodes var networkManager = new NetworkManager(); networkManager.Server = GetNode("Server"); networkManager.ServerObjectManager = GetNode("ServerObjectManager"); networkManager.Client = GetNode("Client"); networkManager.ClientObjectManager = GetNode("ClientObjectManager"); networkManager.SocketFactory = new UdpSocketFactory(); networkManager.MaxConnections = 100; // Start the appropriate mode networkManager.StartServer(); // or StartClient() or StartHost() ``` -------------------------------- ### GameServer Node Setup and Usage Example Source: https://github.com/james-frowen/mirage.godot/blob/main/_autodocs/api-reference/network-server.md Demonstrates how to set up and use the NetworkServer within a Godot Node. It covers initializing the server, setting up event listeners for player authentication and disconnection, starting the server, and manually updating message processing in the _Process loop. ```csharp public class GameServer : Node { private NetworkServer _server; private ServerObjectManager _objectManager; public override void _Ready() { _server = GetNode("NetworkServer"); _objectManager = GetNode("ObjectManager"); // Setup events _server.Started.AddListener(OnServerStarted); _server.Authenticated += OnPlayerAuthenticated; _server.Disconnected += OnPlayerDisconnected; // Start listening _server.Listen(7777); } private void OnServerStarted() { Debug.Log("Server started and listening!"); } private void OnPlayerAuthenticated(NetworkPlayer player) { Debug.Log($"Player {player} authenticated"); // Spawn player character var prefab = GD.Load("res://Player.tscn"); var character = prefab.Instantiate(); AddChild(character); _objectManager.Spawn(character, player); } private void OnPlayerDisconnected(NetworkPlayer player) { Debug.Log($"Player {player} disconnected"); } public override void _Process(double delta) { if (_server.Active) { _server.UpdateReceive(); _server.UpdateSent(); } } } ``` -------------------------------- ### StartHost Source: https://github.com/james-frowen/mirage.godot/blob/main/_autodocs/api-reference/network-manager.md Starts both the server and a local client, enabling host mode for single-player or cooperative gameplay. ```APIDOC ## StartHost ### Description Starts both server and a local client (host mode). Useful for single-player or cooperative games where the host also participates. ### Method `virtual void StartHost()` ### Parameters None ### Returns void ### Throws None ### Example ```csharp networkManager.StartHost(); ``` ``` -------------------------------- ### NetworkClient Usage Example Source: https://github.com/james-frowen/mirage.godot/blob/main/_autodocs/api-reference/network-client.md This C# example demonstrates how to set up and manage a NetworkClient instance within a Godot Node. It covers connecting to a server, handling various connection events, and updating the client's network state each frame. Ensure the NetworkClient node and its dependencies are correctly set up in the scene. ```csharp public class GameClient : Node { private NetworkClient _client; private ClientObjectManager _objectManager; private Label _statusLabel; public override void _Ready() { _client = GetNode("NetworkClient"); _objectManager = GetNode("ObjectManager"); _statusLabel = GetNode