Contents - Quick Links
At this stage of this multiplayer tutorial for Unity we simply have configured the uLink plugin in Authoritative server mode. Since we are creating a Client (the player) Server (the master) architecture, we need to create two different scenes in our project.
- The current scene should be empty with only a Main Camera in it, save this scene and name it ‘client’, then Save it another time and name it ‘server’.
- Make sure you are actually working on the server scene by double clicking on it, as we will look into it first.
uLink approach is to define who is the server and who is the client by attaching scripts as components to gameobjects, as in normal Unity behaviour. by doing this, our server will be different from the clients in terms of functionality and appearance, and it should only implement components vitals to game logic and operation to keep the server memory footprint and processing load low.
- Create an empty Gameobject into the server scene ( Gameobject-> Create empty ) and name it StartServer.
- Add to the StartServer empty gameobject the uLink Utilities’ Simple Server component ( Component –> uLink Utilities –> Simple Server )
The Simple Server component makes the scene a real uLink server that listens for clients communications, the scripts is included in uLink and gives you a basic server which you can configure by modifying the options in the Inspector panel. You can specify the port the authoritative server is listening, the maximum number of players and other advanced configuration options.
Create level environment on server
Our Unity authoritative server is now started, but we didn’t program the clients so nobody will be able to connect to it. We need first to create the actual level where our clients will move their characters, a simple floor with four walls and some fancy lights will be enough for our needs. You can download a simple room made by me in the following link and import it in your project:
Our authoritative server environment setup is completed, we need now to introduce the assets the player will take control of, player avatars, and delve a little inside uLink inner workings to enable the multiplayer component of our game. This will require a little more work on the server scene, see you next page to get started building the network logic on our authoritative server !