

Return base.Initialize(defaultWorldName) // Use the regular bootstrap Public override bool Initialize(string defaultWorldName)ĪutoConnectPort = 7979 // Enabled auto connect

Public class GameBootstrap : ClientServerBootstrap manually decide which worlds (client and server) to create based on user input The bootstrap can also be used to configure other settings as well as to Create a custom bootstrap, which enables auto-connect.
#Cube world server setup code
You can use the auto-connect feature by inheriting from the ClientServerBootstrap, then setting the AutoConnectPort to your chosen port.Ĭreate a file called Game.cs in your Assets folder and add the following code to the file: using System In Netcode for Entities, the simplest way of achieving this is to use the auto-connect feature. To enable communication between the client and server, you need to establish a connection. If you select Play, then select Window > Entities > Hierarchy, you can see two worlds (ClientWorld and ServerWorld), each with the SharedData Scene with the Plane that you just created. To do this, right click the SharedData Sub Scene and select 3D Object > Plane which then creates a planes nested under SharedData.

Once this is set up, we want to spawn a plane in both the client and the server world. Right-click within the Hierarchy window in the Unity Editor.To share data between the server and the client: We achieve this separation in Netcode for Entities by creating a different World for the server and each client (via the Entities Package). To begin, set up a way to share data between the client and the server. This tutorial briefly introduces the most common concepts involved in making client-server based games. Make sure you have set up the project correctly using the installation guide before starting your adventure (of creating a simple client-server based simulation).
