MMO multiplayer tutorial for Unity with uLink authoritative server

MMO multiplayer tutorial for Unity with uLink authoritative server

Share

Configure the authoritative server

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’. 04-ulink-authoritative-server-multiplayer-tutorial
  • 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 )05-ulink-authoritative-server-multiplayer-tutorial

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. 06-ulink-authoritative-server-multiplayer-tutorial

if you now press play in the server scene, you should see in the Unity console that our authoritative server started successfully and printed a message :07-ulink-authoritative-server-multiplayer-tutorial

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:

www.gameobject.net/unity/0001146uLinkAuth/EnvironmentPrefab.unitypackage

08-ulink-authoritative-server-multiplayer-tutorial

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 !

4 thoughts on “MMO multiplayer tutorial for Unity with uLink authoritative server

  1. I have tried tow ork on this. Somehow my client is stuck in “Instantiating”. I am able to move it though but without any effect on the server. The model seems to come back to the spawn point after any movement in the client.

    • Hi ! Do you use the same Unity and uLink versions of this tutorial? I should check and validate this tutorial also with the latest versions. However the issue you refer to is something i recall experiencing while i was coding, the server is overwriting the transform component, please check your project ,every option of the creator owner and proxy objects should match the tutorial.
      Meanwhile i will review the tutorial to check for bugs, maybe we can sort out your problem together.

      Also after a quick look i added a page with a video of the final result you should get, and a link to the project and compiled files. Carefully check the uLink Network view component options of the Proxy, Owner and Creator gameobjects.

      Thanks for your comment !

  2. I could not switch from manual view id to allocated until i had draged the creator prefab into the project folder! just a heads up for anyone who might have the same problem.

Leave a Comment