How to do a simple multiplayer game (2 players, 1 host the game)

Are there any video tutorial for create a multiplayer game? I cant figure out how to create host and send data with udp, or watever protocol.



ok. But I dont understand anything, this is why I ask for a tutorial.

I dont have a server and I dont know How to setup one.

Then you can read:

Like I said before, that documentation is for people that understand something about this stuff.

The documentation of a programm is not a tutorial. If there is not a Tutorial, or more friendly aproach for someone with 0 idea of node.js, or servers , or whatever, its better saying " there isnt" , and I quit.

Its very frustrating understand something that is like chinese for me, from people that think is easy or friendly info when is not at all.

And I dont have a server, I only want to connect 2 defold games each other.

Creating a multiplayer online game is probably the hardest kind of game you can create. I’m not aware of a service that takes care of and completely hides the problems that can happen when two people in completely different locations in the world play, maybe on mobile phones, on crappy internet connections. You must have a basic knowledge of network connections, their different properties and problems.

PlayFab has hosted game servers and they handle login, matchmaking etc and they have have support for Defold. Their official documentation is here:

Colyseus which Selim suggested is more bare bones and you need to do more work yourself, but it is still quite powerful.

There are other services as well. The whole suite of Amazon Web Services and Gamesparks:

Gamesparks does also support Defold, or at least they used to do it.


I just try to encourage you to read. Pill sized solutions are not always available. Multiplayer is require lots of knowledge.

Actually it is not that hard to start a local server on your machine. If you read my example than you need the complete just a few steps to start with it. If you know how to install a application(like installing a game or any other program like Defold) you can simply install and start a server on your own computer.

Also, if you really want to learn I recommend you to start with basics and Colyseus is just suitable for that.

Lets take a look at my example.

  1. You need to install Node.js
    Simply goto this website:
    Download and install. If you really want to learn more about node.js, you can find tons of video tutorials about it.
  2. Download my example project. It is just a Defold project.
    You can download from green button (Clone or Download).
    Extract it
  3. There is a folder caller " server" in the extracted folder : <project_path>/server
  4. I don’t know your OS. If you are on Mac or Lİnux open your Terminal or on windows open Command Prompt(I guess)
  5. Change current directory to extracted folder/server with cd command
> cd /<project_path>/server
  1. And type npm install. This will install all necessary files for you.
> npm install
  1. When istallation finished type npm start. This is going to start your first server with game logic.
> npm start
  1. Open the downloaded project with Defold and run.

If everything goes well(which is mostly not :slight_smile: ) you can connect to server from Defold and you can join the room. You need another client(since this is a two player game) but I’m going to left this to you.

Feel free to ask me anything. I’m sure there will be problems but this is the way of learning. Fail->Solve.


if I do the 6 º and 7º step, when I bundle the game and launch the exe, will work or the pc need something? Can this work in 2 diferent computers?


Did you complete those steps or just asking? Please learn first and think about releasing later.

Baby steps first. If you really want to develop multiplayer game, this is just a small step. Forget about releasing and playing on two different computer. Start with learning on your local environment.
If you really want to develop a multiplayer game, I would recommend you to learn what server is.

1 Like

its for understand what node do, and if this will work without hard configurations and installing node, for the player that want to play the game.

Node.js is a system for running Javascript code outside of your browser. It is nowadays a popular way to run Javascript on a server. Node.js is typically used to run on a server, in this case it is used to run Colyseus on a server somewhere.

The players do not need to install it. You as a game developer working on and later releasing a game need to have it installed on a server somewhere. But first, when playing around with it to learn you have Node.js running a server on your own computer. A Defold game client will connect to this server which is running on the same computer as the game client. Later the game client will connect to the server when it is running on a server somewhere on the internet.


Javascript is simple and easy to understand. This is why I recommend Colyseus. In real world servers it is not acceptable(at least for me). Javascript is simple as Lua. So you can understand the server side logic.

Im going to give up this until I learn more about web development (looking for courses) . Maybe one day I ask you again, how to do this, thanks.