Base connection to Master

Basic connection

  • Create a new scene
  • Create an empty object in the scene and name it, for example --MASTERSERVER*.
  • Select this object and click Add Component and then MasterServerBehaviour.
  • Create a second empty object and name it, for example --MASTER_CONNECTOR*.
  • Select this object and click Add Component and then ClientToMasterConnector.

That's it!

If you now start game in editor you can see console log output:

На скриншоте показано логирование запуска мастер сервера и клиента. Отмеченные строки показывают успешный запуск первого и успешное подключение второго.

How does it all work?

  • MasterServerBehavior starts and checks if it has any modules. If the modules are found, the master server starts each module and connects all the necessary dependencies.
  • ClientToMasterConnector also starts automatically if the ConnectOnStart checkbox is on, otherwise you will have to start the connection either manually or using the command-line argument -mstStartClientConnection.

Can I have the server and client in different scenes?

Of course! Just place an object with the MasterServerBehaviour component in one scene, and an object with the ClientToMasterConnector component in another scene. You can even use them in different projects.

There's really no "best" setup when working with the framework - you do what suits you best.