Making a Lobby to Gather Players Together
In the previous chapter, we discussed how to use UDP packets to exchange data between multiple players in a game. While this approach is highly efficient, it requires a lot of manual work to ensure that data is sent and received correctly. In this chapter, we will explore the high-level network API of the Godot Engine, which simplifies the networking process by providing a set of built-in tools and functions that can handle common network tasks.
Specifically, we will focus on the ENetMultiplayerPeer API, which is the Godot Engine’s wrapper class for its ENet library implementation, and Remote Procedure Call (RPC), a communication protocol that allows us to make calls to functions and methods on remote computers as if we were making them locally. We will use these tools to create a lobby, authenticate players, retrieve player avatar data from a fake JSON database, and synchronize all players when a player enters the lobby. We will...