Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
The Essential Guide to Creating Multiplayer Games with Godot 4.0
The Essential Guide to Creating Multiplayer Games with Godot 4.0

The Essential Guide to Creating Multiplayer Games with Godot 4.0: Harness the power of Godot Engine's GDScript network API to connect players in multiplayer games

eBook
$27.98 $39.99
Paperback
$49.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Colour book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning
Table of content icon View table of contents Preview book icon Preview Book

The Essential Guide to Creating Multiplayer Games with Godot 4.0

Setting up a Server

Welcome to The Essential Guide to Creating Multiplayer Games with Godot 4.0. In this hands-on book, you are going to learn the core concepts used to create online multiplayer games using the Godot Engine 4.0 Network API.

Firstly, we are going to understand some fundamental aspects of how computers communicate through a network and the main protocols, including which ones are more relevant for making online multiplayer games.

After that, we will understand how Godot Engine 4.0 uses and provides both low- and high-level implementations for networking using its network API. We’ll understand some core classes that we can use to pass data around to multiple computers on the same network. And then we’ll focus on the high-level API known as ENetMultiplayerPeer.

With the fundamentals in place, we’ll use the knowledge we just learned to turn local gameplay features into online gameplay features. To do that, we will develop five game projects:

  • An online quiz game
  • Checkers
  • Pong
  • A co-op platformer
  • A top-down adventure

Then, we’ll learn some techniques we can use to improve our players’ experience by optimizing how their game sends, receives, and processes network data. We’ll understand that we don’t need constant updates and that we can do most of the gameplay with small bits of data and let the clients’ computers fill the gaps on their own.

Throughout each chapter, you’re going to do a role play of a network engineer working for a fictional, independent game development studio. In each chapter, you will apply your recently learned knowledge to a fictional problem presented by your studio’s peers. You’ll focus on the network aspect of each project they present, so you don’t waste your precious time trying to understand unnecessary aspects.

In this chapter, you are going to learn the most important aspect of establishing a network of computers: to connect them all together. You’ll see how this process happens, the reason for doing this, what’s required to establish this connection, and how we can do that using the API that Godot Engine provides.

We will cover the following topics in this chapter:

  • Introduction to a network
  • Understanding the Godot Engine Network API
  • Setting up the client side
  • Setting up the server side
  • Making your first handshake

By the end of the chapter, you’ll have a client and server version of an application that establishes the connection of two or more computers. This is the very core of everything that we are going to see throughout the book, and with that knowledge, you’ll understand how you can start making computers communicate within a network, which is exactly what you need to do in online multiplayer games.

Technical requirements

Godot Engine has its own standalone text editor, which is what we are going to use to code all our practical lessons.

As mentioned earlier, in this book you will do a role play of a network engineer of a fictional indie game studio. So, we will provide pre-made projects with all the non-network-related work ready. You can find them in the book’s GitHub repository: https://github.com/PacktPublishing/The-Essential-Guide-to-Creating-Multiplayer-Games-with-Godot-4.0.

With the project properly added to your Godot Engine’s project manager, open the project and move on to the res://01.setting-up-a-server folder. Here, you'll find what you need to follow this chapter (later part).

Introduction to a network

Making a network of connected computers is quite a task. In this chapter, we’ll understand the core concepts of online networks. We’ll also cover how Godot Engine provides solutions to each of the problems we may face in our quest to make online multiplayer games.

A network is a collection of interconnected devices that communicate with each other. In this communication, these devices exchange information and share resources with each other. You can have a local network, such as in a house or office, or a global network, such as the internet. The idea is the same.

For these devices to communicate they need to perform what we call a handshake. A handshake is how one device recognizes another device and establishes their communication protocols. This way, they know what they can request, what they expect to get, and what they need to send to one another.

A handshake begins with one device sending a message to another device. We call this message a handshake request. The devices use this message to start the handshake process. The one that sent the request waits for a message from the one that received it. We call this second message a handshake response.

Figure 1.1 – The handshake procedure

Figure 1.1 – The handshake procedure

When the requested device sends the confirmation through the handshake response, they establish their communication. After that, the devices start exchanging data. This wraps up the handshake process. We usually call the device that requests data the client. As for the one that provides data, we call it the server.

Note that we use these names for the very first interaction. After this first interaction, it is common that these roles change. In that sense, communication is dynamic. The server may request data from the client, and the client may provide data to the server.

In this chapter, we are going to make our first handshake using the Godot Engine Network API. We’ll also create and synchronize players’ data across the network. So, hold tight, as you’ll learn the following:

  • What the ENet library is and why we use it for games
  • How we can make a handshake using the ENetMultiplayerPeer class

For that, you’ll create a Godot project that lists connected players and allows them to edit and sync a line of text. It’s a simple but elegant project that covers the basics of setting up an online multiplayer environment in Godot Engine.

Understanding the ENetMultiplayerPeer class

One of the Godot Engine Network API’s core features is the ENetMultiplayerPeer class. By using this class, we can perform a handshake between our game server and clients.

The ENetMultiplayerPeer class is a high-level implementation of the ENet library. Let’s understand this library and why we use it in online multiplayer games.

What is the ENet library?

ENet is a lightweight, open source networking library that is widely used in the game development industry. It is designed to be a high-performance, reliable, and easy-to-use library for creating multiplayer games and other networked applications. One advantage of the ENet library is that it’s cross-platform and written in C. So, it’s efficient with a small footprint and low overhead.

The library provides a simple and easy-to-use API that makes it easy for developers to create and manage network connections, send and receive packets, and handle network events such as disconnections and packet loss.

Packets, in this context, are small units of data that servers and clients transmit over the network. We use them to transmit information such as game state, player input, and other types of data between different devices on the network.

The ENet library offers support for multiple channels that allow us to easily create multiple streams of data, such as voice and video, within a single connection. This is excellent for many multiplayer games.

Another reason to use ENet in multiplayer games is its easy-to-use networking library that is based on the UDP protocol. This is a good chance to understand one of the main network protocols, so let’s do it.

What is the UDP protocol?

The UDP protocol is a connectionless protocol that is well suited for real-time, high-bandwidth applications such as online gaming. This is because it has low latency and is able to handle high throughput. Just so we are on the same page, in the world of network terms, latency refers to the time between the transmission and receiving of data through the network.

For instance, it’s very common to talk about lag in online multiplayer games: the time between the player performing an action and the game reacting to it. The next figure illustrates how latency works and is calculated:

Figure 1.2 – Visual demonstration of latency

Figure 1.2 – Visual demonstration of latency

It’s basically how much time it takes for data to cross the network, be properly handled by the server, and to provide a response to the client.

Throughput refers to how much data we can send through a given network route within a time period before it gets overwhelmed. For instance, this is a fundamental concept when we talk about DDoS attacks, where hackers overwhelm the server with an immense number of unsolved requests, preventing other clients from accessing the service. In the following figure, you can see a visual representation of the throughput concept:

Figure 1.3 – Visual demonstration of throughput

Figure 1.3 – Visual demonstration of throughput

The bandwidth is how big the available channel of communication in the network is. You can think of it as a pipe that streams data. A bigger pipe allows a lot of data, and big data, to be transmitted at any given time, while a small pipe may not even allow any data, of any size, to be transmitted. You can see this concept illustrated in the following figure:

Figure 1.4 – Visual demonstration of bandwidth

Figure 1.4 – Visual demonstration of bandwidth

Unlike the more commonly used Transmission Control Protocol (TCP), User Datagram Protocol (UDP) does not establish a dedicated connection between two devices before transmitting data. Instead, it simply sends packets of data to a specified destination address without ensuring that the packets have been received or acknowledged.

Sounds… bad, right? But it’s quite the opposite.

This lack of reliability is often seen as a drawback of UDP, but in the context of online multiplayer games, it can actually be an advantage. In games, where responsiveness and low latency are critical, the overhead of establishing and maintaining a connection can be a significant bottleneck.

By not requiring a dedicated connection, UDP allows for faster and more efficient transmission of data. Additionally, since UDP does not require the receiver to acknowledge receipt of packets, it is less affected by network congestion or delays, which can be critical for maintaining a stable and responsive connection in a high-bandwidth, high-latency environment such as online gaming.

Furthermore, the lack of reliability of UDP can actually be beneficial in the context of online multiplayer games. In games, where a small amount of packet loss or delay can have a large impact on the players’ experience, it’s important that the game can adapt to these types of network conditions. By not providing guarantees on packet delivery, UDP allows the game to handle packet loss and delay in a way that is most appropriate for the specific game and its mechanics.

Think about the following situation.

We establish a connection. In this connection, we update all players in the network about all other player avatars’ positions in the world. This way, everyone shares the same world state.

If we use a TCP protocol, everyone will have to wait for every other player to send their position and confirm that they have received every change in every other player’s position, while also trying to maintain the correct chronological order in which the positions have changed.

So, in this example, if a player moves five units to the left and sends 15 packets with all the movement data, including being idle, all other players must confirm that they have received all those 15 packets.

Using UDP, players can ignore every update but the latest one, which is the only relevant piece of information in real-time experience: what is the game-world state now? It doesn’t matter how it gets to this point; it only matters that it is there at this very moment.

We are going to see that this causes some trouble as well. But we can create methods and understand techniques to mitigate those issues. We are going to talk about that in further chapters.

How does this connection happen?

To establish a UDP connection, we need two core things:

  • The IP address of the peers, mainly the server
  • The port over which they will exchange data

For test purposes, on all our projects we are going to use the localhost IP address. This is a shortcut to your local IP address mask. An IP address is like a house or apartment address. It is the exact location to which a given packet should be delivered and represents the address of the computer in the network. A port is essentially a specific channel in which the host allows a given communication to be established; we’ll use the 9999 as our default port. There’s nothing special about this one; it’s just an arbitrary pick.

With this in mind, let’s see for the first time the ENetMultiplayerPeer class in action. As you can imagine, this setup requires a two-sided approach. We need to set up a game architecture for our server and a different architecture for our client.

Let’s start with the server architecture.

Creating the server

The ENetMultiplayerPeer class in the Godot Engine provides a convenient way to create and manage network connections for online multiplayer games. One of the most important methods of this class is the create_server() method, which is used to create a new server that can accept connections from clients. This method is simple to use and, besides having five arguments, it only requires one to get started:

  • The first argument of the ENetMultiplayerPeer.create_server() method is the port on which the server will listen for incoming connections. This is the port number that clients will use to connect to the server. For example, if you want the server to listen on port 9999, you would call ENetMultiplayerPeer.create_server(9999). This is the only mandatory argument to call this method.
  • The second argument is max_clients, which is the maximum number of clients that the server will allow to connect at the same time. This argument is optional, and if not specified, the server will allow up to 4,095 clients to connect.
  • The third argument is max_channels, which is the maximum number of channels we allow the server to use per client. Channels are used to separate different types of data, such as voice and video, and are useful for creating multiple streams of data within a single connection. This argument is optional, and if not specified, the server will allow an unlimited number of channels.
  • The fourth argument is in_bandwidth, which is the maximum incoming bandwidth that the server will allow per client. This argument is optional, and if not specified, the server will allow unlimited incoming bandwidth.
  • The fifth argument is out_bandwidth, which is the maximum outgoing bandwidth that the server will allow per client. This argument is optional, and if not specified, the server will allow unlimited outgoing bandwidth.

Let’s create our server in Godot Engine. Open up the project provided in the GitHub link given previously. After opening the project, execute the following steps:

  1. Create a new scene and use a Node instance as the root.
  2. Attach a new GDScript to this node, and name it Server.gd.
  3. Save the scene and open the script.
  4. Define a constant called PORT and set it to our default port number so the server can listen to it:
    const PORT = 9999
  5. Create a new ENetMultiplayerPeer using the new() constructor. Let’s store it in a variable called peer:
    var peer = ENetMultiplayerPeer.new()
  6. In the _ready() function, call the create_server() method on the peer variable, passing in the PORT constant as an argument:
    func _ready():
        peer.create_server(PORT)
  7. Still in the _ready() callback, assign the peer variable to the built-in multiplayer member variable of this node:
        multiplayer.multiplayer_peer = peer
  8. Connect the peer_connected signal of the multiplayer variable to a function called _on_peer_connected. We’ll create this callback method next:
    multiplayer.peer_connected.connect(_on_peer_connected)
  9. Create a new method called _on_peer_connected(), which should receive peer_id as the argument:
    func _on_peer_connected(peer_id):
  10. In the _on_peer_connected() function, use print() to print the passed peer_id argument on the console:
      print(peer_id)

    The complete script should look like this:

    extends Node
    const PORT = 9999
    var peer = ENetMultiplayerPeer.new()
    func _ready():
        var error = peer.create_server(PORT)
        multiplayer.multiplayer_peer = peer
        multiplayer.peer_connected.connect
            (_on_peer_connected)
    func _on_peer_connected(peer_id):
        print(peer_id)

It’s important to note that this script uses the built-in multiplayer member variable that every Node instance has on Godot Engine 4.0 Network API, which is an instance of the MultiplayerAPI class.

Done: we have our server ready. Told you it would be simple!

Creating the client

Next up, let’s create our client. The process is quite similar. The major difference is that the client needs the server IP address to find it on the network.

We use the ENetMultiplayerPeer.create_client() method to connect a client to a server. This method is very simple to use and requires only two arguments to work:

  • The first argument of the create_client() method is the address of the server. This can be either the server’s IP or hostname. For instance, if you want the client to connect to a server with the IP address 192.168.1.1, you would call create_client("192.168.1.1"). But to make things simpler, we’ll use "localhost", which is a shortcut to our own IP address mask.
  • The second argument of the create_client() method is the port on which the server is listening for incoming connections. This is the port number that the client will use to connect to the server. For example, if the server is listening on port 9999, you would call create_client("192.168.1.1", 9999).
  • The third argument of the create_client() method is channel_count, which is the number of channels that the client will use to communicate with the server. Channels are used to separate different types of data, such as voice and video, and are useful for creating multiple streams of data within a single connection. This argument is optional, and if not specified, the client will use a default value of 1 channel.
  • The fourth argument of the create_client() method is in_bandwidth, which is the maximum incoming bandwidth that the client will allow per connection. This argument is optional, and if not specified, the client will use a default value of 0, allowing an unlimited incoming bandwidth.
  • The fifth argument of the create_client() method is out_bandwidth, which is the maximum outgoing bandwidth that the client will allow per connection. This argument is optional, and if not specified, the client will use a default value of 0, allowing an unlimited outgoing bandwidth.
  • The sixth argument of the create_client() method is local_port, which is the local port that the client will bind to. This argument is optional, and if not specified, the client will use a default value of 0.

Now, let’s see how we can create the client side of this connection so it can connect with our server and establish their handshake:

  1. Create a new scene and add a Node instance as the root.
  2. Attach a new script to it.
  3. Save the script as Client.gd.
  4. In the script, define a constant called ADDRESS and set it to the server’s IP. In this case, we are going to use "localhost":
    const ADDRESS = "localhost"
  5. Define a constant called PORT and set it to be our default port number. It’s very important that this matches the number we used in Server.gd, otherwise these peers won’t be able to find each other:
    const PORT = 9999
  6. Create a new ENetMultiplayerPeer using the new() constructor and store it in a variable called peer:
    var peer = ENetMultiplayerPeer.new()
  7. In the _ready() callback, call the create_client() method on the peer variable, passing in the ADDRESS and PORT constants as arguments:
    func _ready():
      peer.create_client(ADDRESS, PORT)
  8. Assign the peer variable to the built-in multiplayer member variable of the node:
    multiplayer.multiplayer_peer = peer

    The complete script should look like this:

    extends Node
    const ADDRESS = "localhost"
    const PORT = 9999
    var peer = ENetMultiplayerPeer.new()
    func _ready():
        peer.create_client(ADDRESS, PORT)
        multiplayer.multiplayer_peer = peer

Alright, we have our server and our client ready. Now, how do we test them?

Testing our handshake

Godot Engine 4.0 has a useful feature for debugging: the ability to open multiple independent instances of the game. This feature allows us to test different scenes at the same time, making the debugging process much easier and faster.

To open multiple instances of the game, we need to select one option from up to four options in the Debug | Run Multiple Instances menu.

Figure 1.5 – The Run Multiple Instances menu

Figure 1.5 – The Run Multiple Instances menu

Then, as soon as we press the Run Project or Run Current Scene button, Godot will launch the instances we’ve set previously. Let’s stick with two instances for this project.

This feature is incredibly useful for testing online multiplayer games, as it allows us to open a server and a client in the same run. But, as you can see, it’s not very straightforward. When we run the project, it actually opens two instances of the same scene.

Let’s create a minimal menu where we can select whether we are a client or a server:

  1. Create a new scene and use Control as the root and name it MainMenu.
  2. Add a Label node as a child of the root node.
  3. Add two Button nodes as children of the root node.
  4. Give the first Button the name ClientButton and the second one ServerButton:
Figure 1.6 – MainMenu’s Scene tree structure

Figure 1.6 – MainMenu’s Scene tree structure

  1. Set the Button nodes’ text properties to I’m a client and I’m a server respectively and position them side by side in the middle of the screen.
  2. Set the Label node’s text property to Are you a… and position it in the middle of the screen.
Figure 1.7 – MainMenu’s scene UI

Figure 1.7 – MainMenu’s scene UI

  1. Attach a new GDScript instance to the MainMenu node and open it.
  2. Connect the ClientButton’s pressed signal to a function called _on_client_button_pressed.
Figure 1.8 – ClientButton’s pressed signal connection

Figure 1.8 – ClientButton’s pressed signal connection

  1. Connect the pressed signal of the ServerButton to a function called _on_server_button_pressed.
  2. In the _on_client_button_pressed() callback, let’s call the change_scene_to_file() method on the get_tree() instance, passing in "res://Client.tscn" as the argument:
    extends Control
    func _on_client_pressed():
        get_tree().change_scene_to_file
            ("res://Client.tscn")
  3. In the _on_server_button_pressed() callback, do the same as before, passing "res://Server.tscn" instead.

    The complete script should look like this:

    extends Control
    func _on_client_pressed():
        get_tree().change_scene_to_file
            ("res://Client.tscn")
    func _on_server_pressed():
        get_tree().change_scene_to_file("res://Server.tscn")

Now, let’s make sure we save the scene before we test it. After that, all we need to do is hit the Run Current Scene button and watch the scene come to life. All the hard work has been done, and now all that’s left is to appreciate the results.

Once we have the two debug instances running, we need to pick one to be the server first. For that, we can press ServerButton. This will launch our Server.tscn scene and start listening for incoming connections.

Then, in the other instance, we need to press ClientButton. This will launch the Client.tscn scene and try to connect to the server. If everything goes as expected, we should get peer_id printed in the console of the server instance.

This means that the client and the server have successfully established a connection and are now ready to start exchanging messages. Congratulations, you’ve just created your first handshake!

Summary

In this chapter, we went through the fundamentals of network connections, which is to establish the connection through a procedure known as the handshake.

The handshake ensures that two computers recognize each other in a network and establish the protocols of this communication. This is important to understand, as it is the core of all our further endeavors. Without this at our disposal, our players and our server would be disconnected. One would be sending data to the void, while the other would be infinitely waiting for something to arrive.

Talking about sending data, now that we have our computers connected and open to receive and send data back and forth, it’s time to see how to do that. Throughout this chapter, you saw how you can properly establish a connection using the ENet library and how Godot Engine provides a high-level approach to handshaking, to the point that we can barely see if there was an actual handshake or not.

In the next chapter, we are going to use the UDP protocol to also establish a connection between client and server. But this time, we are going to dig a bit further and actually send data both from the client to the server and the other way around.

It’s important to use the UDP protocol to understand what might be happening under the hood when we finally start to get used to the Godot Engine ENetMultiplayer API.

Now let’s see the dirty and messy world of low-level data transmission in the next chapter, so we can understand later how much easier our lives are made with the new high-level network API!

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Ensure player synchronization and coexistence in a game world
  • Mitigate latency in your multiplayer games to design a seamless shared experience
  • Optimize and debug your games using profilers and monitors to visualize performance
  • Purchase of the print or Kindle book includes a free PDF eBook

Description

The Essential Guide to Creating Multiplayer Games with Godot 4.0 guides you in exploring the built-in network API for online multiplayer games, offering practical knowledge through concrete use cases. Throughout the book, you'll assume the role of a network engineer in a fictional indie game studio, tackling real-world requests from your peers and gaining expertise in adding new network features to the studio's games. Following step-by-step instructions, you’ll go from making your first network handshake to optimizing online gameplay. You’ll learn how to sync players and pass data over the internet as you add online multiplayer features to a top-down shooter adventure game. This book puts you in a fictional game project team where you set up your first online server before advancing to creating an online chat system and transitioning local gameplay to go online. With a focus on implementing multiplayer features, you’ll create shared world adventures and learn optimization techniques to allow more players to join your virtual world. By the end of this book, you’ll have learned how to set up a client-server network, implement remote procedure calls (RPCs), sync node properties remotely, and optimize your games to create smooth online multiplayer experiences.

Who is this book for?

If you’re involved in game development with Godot and want to add multiplayer capabilities to enrich the shared gaming experience, then this book is for you. You’ll also find this book useful if you’re a network engineer looking to gain hands-on experience with practical projects. To get the most out of this book, a prior understanding of the Godot Engine design philosophy, the GDScript programming language, the SceneTree structure, and how nodes work is essential.

What you will learn

  • Understand the fundamentals of networking and remote data exchange between computers
  • Use the Godot game engine's built-in API to set up a network for players
  • Master remote procedure calls and learn how to make function calls on objects remotely
  • Enhance your GDScript proficiency to get the most out of this powerful language
  • Explore industry-standard solutions for common online multiplayer challenges
  • Improve your networking skills and discover how to turn single-player games into multiplayer experiences
Estimated delivery fee Deliver to Turkey

Standard delivery 10 - 13 business days

$12.95

Premium delivery 3 - 6 business days

$34.95
(Includes tracking information)

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Dec 22, 2023
Length: 326 pages
Edition : 1st
Language : English
ISBN-13 : 9781803232614
Languages :
Tools :

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Colour book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning
Estimated delivery fee Deliver to Turkey

Standard delivery 10 - 13 business days

$12.95

Premium delivery 3 - 6 business days

$34.95
(Includes tracking information)

Product Details

Publication date : Dec 22, 2023
Length: 326 pages
Edition : 1st
Language : English
ISBN-13 : 9781803232614
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total $ 139.97
Godot 4 Game Development Projects
$44.99
The Essential Guide to Creating Multiplayer Games with Godot 4.0
$49.99
Godot 4 Game Development Cookbook
$44.99
Total $ 139.97 Stars icon

Table of Contents

18 Chapters
Part 1:Handshaking and Networking Chevron down icon Chevron up icon
Chapter 1: Setting up a Server Chevron down icon Chevron up icon
Chapter 2: Sending and Receiving Data Chevron down icon Chevron up icon
Chapter 3: Making a Lobby to Gather Players Together Chevron down icon Chevron up icon
Chapter 4: Creating an Online Chat Chevron down icon Chevron up icon
Part 2:Creating Online Multiplayer Mechanics Chevron down icon Chevron up icon
Chapter 5: Making an Online Quiz Game Chevron down icon Chevron up icon
Chapter 6: Building an Online Checkers Game Chevron down icon Chevron up icon
Chapter 7: Developing an Online Pong Game Chevron down icon Chevron up icon
Chapter 8: Creating an Online Co-Op Platformer Prototype Chevron down icon Chevron up icon
Chapter 9: Creating an Online Adventure Prototype Chevron down icon Chevron up icon
Part 3:Optimizing the Online Experience Chevron down icon Chevron up icon
Chapter 10: Debugging and Profiling the Network Chevron down icon Chevron up icon
Chapter 11: Optimizing Data Requests Chevron down icon Chevron up icon
Chapter 12: Implementing Lag Compensation Chevron down icon Chevron up icon
Chapter 13: Caching Data to Decrease Bandwidth Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.4
(17 Ratings)
5 star 76.5%
4 star 5.9%
3 star 5.9%
2 star 5.9%
1 star 5.9%
Filter icon Filter
Top Reviews

Filter reviews by




Roman Perry Jan 03, 2024
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book is a very solid introduction to creating multiplayer games in Godot. It is great for devs who already have some experience with creating games and are curious about taking the first steps towards networked, multiplayer games. The five projects outlined within the book will give anyone a solid foundation for their own multiplayer games.I've been following the writer of the book, PigDev, for a very long time and he has always produced quality content. I'm excited to dive in and start these projects!
Amazon Verified review Amazon
G Money Dec 31, 2023
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This is a rare book that really manages to walk you through a progressive set of examples that will take you from building simple network topologies to more advanced ones while explaining the design decisions along the way. For people not familiar with the subject, I would encourage you to read the whole book and not just skip to what you might consider as the network architecture for your game, as also g the way the author will have explained many of the design concerns that led to that topology and your requirements may necessitate a different approach which the author tends to dive into. This book will serve as a strong reference for Godot4 multiplayer and I definitely recommend reading it if you are diving into multiplayer as opposed to just watching a few YouTube videos and trying to go it alone without understanding WHY things work the way they do.
Amazon Verified review Amazon
Jacob Feb 13, 2024
Full star icon Full star icon Full star icon Full star icon Full star icon 5
As a hobbyist within the video game programming, it's sometimes a bit difficult finding good material to learn from, especially when it comes to advanced topics, such as Godot networking. However, I do think that this book stands out in the vast sea of knowledge as a primary example of how Godot networking should be taught.Right off the bat, the book does an excellent job at giving a very general understanding at basic networking concepts (client, server, packets, etc), all within a few pages. Whenever a new Godot networking concept is brought up, you receive a brief introduction to the concept before it's implemented into your project. It's great, and very efficient, to not be stuck talking about such basic concepts for too long. It allows us to focus on networking in Godot specifically, which I found very nice. Additionally, one thing this book has that you don't always find everywhere else is the discussion of certain advanced networking topics, such as network debugging within Godot or implementing lag compensation within a Godot project. These are very important topics to be learning about, especially if you want to get serious about Godot development, and you won't always find this information on other tutorials or books, which is why I find it fantastic that it's talked about with such detail in this book.Another thing I love about this book is how it introduces the example project code to you in smaller blocks, one at a time. In programming books, I often see an author drop massive amounts of code at a time, just to spend the next 10 paragraphs breaking down that code, which isn't inherently a bad thing, but in my opinion, it gets a bit hard to understand the logic and keep track of everything that's going on when a code block and the explanation are so large. In this book, it takes a slightly different approach. Instead, it will give you smaller blocks of code at a time, followed by a small paragraph explaining what is going on, which, in my opinion, is a bit more effective. It allows you to better process what the author is discussing, which helps you easily understand the bigger picture.In addition, this book does have a GitHub repository with all of the project files that you can pull onto your local computer to follow along with what's going on in the book, which is very nice. I would *highly* recommend using this, if possible, and following along with the book, as it helps you get a better insight as to what is going on. However, one thing I will mention is that there are some *very* small coding difference between what is the GitHub repository files and what is in the book examples. Do these differences actually matter? No, not at all. I only bring it up because it might confused some readers who are not as experienced with the Godot video game engine.Will this book turn you from a Godot networking beginner to a Godot networking master? No, but it's a fantastic place to start. Not only does the author make it easy to understand such important Godot networking concepts, but it also gives you the opportunity to experiment and learn just how powerful Godot networking can be, which can then be easily applied into your own projects. If you are already knowledgeable in Godot programming and need to take the first step into Godot networking, this book is the perfect place to start.
Amazon Verified review Amazon
Mason Storms Dec 28, 2023
Full star icon Full star icon Full star icon Full star icon Full star icon 5
It's very in depth and answers all the important questions I had. I also appreciate how it is split into multiple sections for different project types and has a focus on optimization.
Amazon Verified review Amazon
ROBERTO HILSACA Jan 10, 2024
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I would recommend for new developers looking to expand their knowledge in setting up multiplayer connectivity but I would in fact also apply knowledge on how servers work and what configuration you need when handling outbound connections. Like mentioned before it sets a foundation for initial configuration and understand of cross communication using Godot.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela