-
Notifications
You must be signed in to change notification settings - Fork 104
Getting Started
No matter what you're building with the framework, there will always be two main components:
- Master Server - a central server, to which everything connects - players, game servers, spawners and etc.
- Connection To Master Server (Client) - connection, over which clients communicate with the master server
- Create a new scene
- Drag a
Barebones/Msf/Prefabs/MasterServer
prefab to the scene - Drag a
Barebones/Msf/Prefabs/ConnectionToMaster
prefab to the scene
And that's it!
This is the core concept of the framework, and it's all you need to work with it. Everything else is just examples of how to use the API, and some helpfui UI components if you're too lazy to make your own.
If you hit the "Play" button in editor, you should see two messages:
ℹ️ Barebones/Demos/Basics/Scenes/Basics-1. Master And Client
scene contains an example, where master server and client connects manually, when user clicks a button.
-
MasterServer prefab starts the master server
- Initializes all of the modules that it can find in the scene.
- ConnectionToMaster keeps trying to connect to the master server automatically, so when master server is started, connection is established.
So with these two prefabs, your scene becomes both - the master server, and the client.
Of course, just add the MasterServer to one scene, and ConnectionToMaster to another. In fact, you can have them in completely different projects!
There's really no "best" setup when working with the framework - you do what suits you best.
It's probably not enough to see the console message, especially if we're making a build, so let's add a simple HUD indicator, which would show us the status of connection, and whether or not the master server has started
- Create Canvas in the scene, by going to
GameObject > UI > Canvas
. - Drag a prefab
Barebones/MsfUiSamples/Prefabs/MsfHUD
as a child of Canvas
Hit a Play button, and you should see the HUD ( ℹ️ you might need to click on the header to expand it)
- Go to
File > Build Settings
, and add current scene - Make a build to any location you like (I made mine in
D:/Build/Win/Build.exe
) - Open command prompt / terminal at the location where you made a build, and run the command
./Build -msfStartMaster
. This should start a master server. - Open the build without the
-msfStartMaster
, or by simply opening it while the master server is running, and you should see this indication:
This way, you have two instances of unity running:
- One is both - master server and client
- The other one is just a client
- Start working with the API and default modules
- Learn to use the Spawner (if you need it)
- Write your own modules