Edge Multiplay is a multiplayer solution where the server is nodeJS and the client is unity
Edge Multiplay is a free and open-sourced Multiplayer solution

Unity & nodeJS Multiplayer Explained

Ahmed Schrute
3 min readMar 26, 2021

--

In this tutorial, I’ll be talking about understanding multiplayer games using Edge Multiplay, Edge Multiplay is a multiplayer solution where the server is nodeJS and the client is unity.

Edge Multiplay is a free and open-sourced Multiplayer solution.

I have here a small example where I’m going to enter my name and press start game.

EdgeMultiplay Starting scene example
Starting Scene

I’ll see some text generated.

Text generated by the server on my unity app
Generated text by the server on my Unity Project

The game will start and I will be playing with another player called Bruce.

The game started between two players
The game started between two players

Now let’s go deeper and understand what happened after I pressed the Start Game Button.

When I pressed the Start Game Button, I sent a request to the network manager with my location.

Sending my Location to the Network Manager
Sending my Location to the Network Manager

The network manager will find the closest server to my location, and once the server is found the connection between me and the server will be initiated.

The network manager will locate the closest server and connect me to it
The network manager will locate the closest server and connect me to it

Next, I will need to provide a key to the server so I can enter the lobby.

Authentication example to enter the lobby
Authentication example to enter the lobby

There are no rooms available in the lobby so I’ll have to create my room and the room will be for two players only (according to my game logic).

Dynamically creating a room since there are no rooms in the lobby
Dynamically creating a room since there are no rooms in the lobby

Bruce has been through the same process but now he finds that my room has a vacancy and he will join my room.

Matchmaking based on vacancy only
Matchmaking based on vacancy only

Once the server noticed that the room is full the server will announce the start of the game.

Inside the room, me and Bruce will be exchanging messages.

For messages like the ball movement or the paddle position, those will be UDP messages.

For more reliable messages like score, those will be web-socket messages.

UDP & Websockets for exchanging messages between room members
UDP & Websockets for exchanging messages between room members

To learn more about edge multiplay, please consider the following

Join our Discord Server:

And check the EdgeMultiplay Getting started tutorials:

--

--