• Tutorials
  • Ultimate Multiplayer | Dedicated Server | Tutorial Series

When I started out learning Godot multiplayer myself I found a massive lack of resources that teach proper network architecture and how to set that up for dedicated servers. I understand why though, it is a deep rabbit hole to dive into. So that sounds like a perfect challenge for me :)

In this tutorial, you will not only learn how to make use of an RPC call to connect a client and a server and get some bullets flying around. I will teach you a proper, scalable network architecture, that has all the ingredients it needs for the secure handling of passwords and other private data that we as developers are responsible for keeping safe.

Couple of things to keep in mind: 1) Although scalable, and when expanded able to handle up to (tens of) thousands of connections. Don't think this is going to be a 'how to make WoW' with a million concurrent users. That requires an entire rethink of the network, but this is going to be enough for starting developers all the way up to an established IndieDevs. After that, go hire a network specialist. 2) I'm going with a Godot-only approach here. Yes, you can also throw a node.js or something else in. That is not the point of this tutorial, + Godot's ENet integration is one of the most efficient and elegant I have seen. So you will be fine. 3) I may in the future dive into SQL-tutorials for the database backbone, for now, we will take it easy. Let's first have you learn networking, security, syncing, and network patterns before we also have you learn SQL. Walk before attempting to run.

Part 1: the basic connection nearly all other tutorials teach you, got to start somewhere right :)

Part 2: how to structure all those functions on your server to not have everything clogged up within 2 months of development. Got to keep things manageable and maintainable.

Part 3: how to have a player login to the network. Although easy with one server, having only 1 server exposing your network to all sorts of attacks and it is just very very very bad practice. Don't do it, take responsibility as a dev. So we will start working on our network, and do it the proper way.

Note: this does not include security yet like hashing and salting your passwords or protecting your authentication server with, for example, VPN and/or IP filters. Those will be future videos.

Part 3B, if you don't know how to make a login screen yet, haven't dabbed into the UI creation of Godot? I got you covered, learn how to make that login screen in just a couple of minutes.

Part 4: now that I got you all bored with network stuff, let's take a break from that and learn how we are going to handle player data.

Announced in earlier video, your network architecture will have to be determined by the type of game, and the type of player interaction. Learn about server limitations, and how to take these limitations into account when you design your network.

We are going to highly secure the network from outside intruders and people that are after our player's passwords, but we can't run highly encrypted communication between our players and our game servers. That would create to much latency. Therefor we use token verification to ensure only authorized players can log onto our game servers.

Time to secure the connection between clients and gateways so packet sniffers and man in the middle attacks are a thing of the past

Give players the option to make their own accounts

Saving 'naked' passwords is always a bad idea. Use hashing and salting to ensure that if a database is leaked/stolen. The data will still be useless

Time to get into the fun stuff =) Spawning other players into the map

Syncing players up using world_state snapshots

Using interpolation to smooth the movement of other players

Extrapolating when our connection was hanging or packets were lost

7 days later

Thank you Stefan! I found all of your tutorials to be the best source for practical, in-depth and real game building with Godot. Combine with the fundamentals and theory tutorials of the channel Godot Tutorials, it is the best way for me to understand the platform. Please keep up with the good work.

@gargara said: Thank you Stefan! I found all of your tutorials to be the best source for practical, in-depth and real game building with Godot. Combine with the fundamentals and theory tutorials of the channel Godot Tutorials, it is the best way for me to understand the platform. Please keep up with the good work.

Thank you Gargara! Messages like these always make me start my day with a smile on my face :) Hope you will find future content equally useful :)

9 days later

I've added two more videos to the video list above. Already working on the next video for DTLS/SSL certificate encrypted communication for our players to login securely.

a month later

Videos for DTLS, Account Creation, and Hashing & Salting have been added

a month later

Synchronizing the clocks of all clients to the server clock

Videos for - Spawning players - syncing players - Interpolation - Extrapolation - Clock Synchronization

have all been added to the list

2 months later

Spawning server-side enemies that are governed by the server

Syncing the animations across clients for both idle/walk/shoot

Creating server maps to remove hit detection from the client (this way the player can't fool the server anymore about what it hits)

And the implementation of that server-side hit detection

5 months later

I also want to say a token of appreciation for the all these tutorials you have done to help us, really thanks they are very useful and not only helping Godot users but any users in general wanting to understand the topology, concept and way of building reliable online multiplayer games.

Thanks is not enough Stefan :) Bit hats off to you.

@supermonster said:

Thanks is not enough Stefan :) Bit hats off to you.

My pleasure, it has been a lot of fun working on that series :)

7 days later

Great tutorial-series. But I had one large issue: When using the ms of the OS as a timestamp on the network messages I had my chracters jumping around for no reason even when they where not moved at all and the position did not change at all.

I could solve this by using a "handcounted" framenumber as a timestamp. I do not understand why it is like that but this is 100% reproducable for me.

Maybe this helps somebody else.

7 days later

@Stefan_GameDev I haven't watched the videos yet, just scrolled through to see what you cover, but it looks amazing! It looks like it covers everything! My current projects don't need this much complexity in networking (only planning on getting pve co-op in my current project) but if I go bigger I no where to go! It's great to see someone go so in depth, a lot of people stick with beginner tutorials. thanks, and keep on game deving!

2 months later

The final part with some tips and hints.

There is many more parts I would love to make. Load balancing Chat Server hand-offs SQL and noSQL integration

These topics will have to wait when I re-do this series in Godot 4.0.