Setting up Nakama

Hi, I am making a game with unity. I have read over the docs multiple times but I really don’t know how to use docker. Here are the steps I have done.

Installed Docker

Imported the Unity Nakama Asset

Can someone help me?

Hi @UnityNoob welcome :wave:

Happy to help get you started as best I can. There’s a few details you should note as you kick off your development with Nakama:

  1. You’ve likely guessed because of Docker engine but Nakama runs as a server outside of Unity engine. You start it from the cmdline when you do development and stop it when you’re done separately to your workflow within Unity.

  2. Docker engine is a tool to run multiple bits of software in “containers”. The value of containers is outside the scope of this post but there’s lots of resources online about it. We take advantage of Docker with “docker-compose” a tool that comes with Docker and lets you describe how more than one container should be run together. With Nakama this is a database and the game server itself.

  3. When you’ve got Docker installed you should download this file from either the docs or the server repo:

    You can then tell Docker compose to run the file docker-compose -f ./docker-compose.yml up in a Powershell window. This will download the database and the game server and start them.

  4. If all starts without any issues you’ll see lines in your Powershell window with the last one which shows:

    {“level”:“info”,“ts”:"…",“msg”:“Startup done”}

    This shows the game server has started and can connect to the database.

  5. Finally you can write some simple code in Unity editor in a C# script to start to add features to your game:

    // using Nakama;
    var client = new Client("defaultkey");

    There’s a bunch of code snippets you can see for basic patterns here and there’s a full game project in Unity which you can see the source code for here. Also have a look at the guide which covers the overall design of the Unity client:

  6. When you’re done with your development or want to stop the server for some other reason just run docker-compose -f ./docker-compose.yml down.

A lot of these steps are covered on the Docker quickstart guide if you need a place to check the commands later:

Hope this helps.