Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
The Essential Guide to Creating Multiplayer Games with Godot 4.0

You're reading from   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

Arrow left icon
Product type Paperback
Published in Dec 2023
Publisher Packt
ISBN-13 9781803232614
Length 326 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Henrique Campos Henrique Campos
Author Profile Icon Henrique Campos
Henrique Campos
Arrow right icon
View More author details
Toc

Table of Contents (19) Chapters Close

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

What this book covers

Chapter 1, Setting up a Server, explains what a network is and how Godot Engine implements networking features through its ENet library implementation. You’ll learn how to make your first handshake to effectively connect a server and a client machine.

Chapter 2, Sending and Receiving Data, discusses the foundation of a network, which is for multiple computers to exchange data with each other. In this chapter, you will learn that we use a data structure called packets, and we serialize data to recreate game states on the network. For this, we use the UDP protocol. At the end, we will have a login screen, effectively retrieving data from the server.

chapter 3, Making a Lobby to Gather Players Together, explains how Godot Engine eases the process of serializing and exchanging data using the industry-standard UDP protocol by providing Remote Procedure Calls (RPCs), allowing us to essentially make calls to methods on remote objects. By the end of the chapter, we expand the login screen into a lobby, adding another client to the equation and connecting three computers together.

Chapter 4, Creating an Online Chat, explains that with the power of RPCs, we can now change objects’ states remotely with ease. In this chapter, we learn how we use RPCs to allow players to exchange messages in a chat. We discuss how we can use RPCs and channels to prevent network bottlenecks. With that, we prepare ourselves to implement actual game features. By the end of the chapter, we will have a fully functional chat.

Chapter 5, Making an Online Quiz Game, explains how we can synchronize players’ game states based on the general game state. We will set up a server that will react to player interactions and change the game state from waiting for a response to processing a match winner, announcing the winner, starting a new match, and reaching the end of available quiz questions, effectively ending the game. By the end of the chapter, we will have an online quiz game where multiple players compete to answer the most questions correctly.

Chapter 6, Building an Online Checkers Game, moves on to implementing a turn-based multiplayer online game, and nothing is better than the classic checkers for that. In this chapter, we will learn how to get the most out of our RPCs while still maintaining the heavy processing on players’ machines. We will also discuss MultiplayerSynchronizer, a node that allows us to easily synchronize nodes’ properties remotely. We will also learn what Multiplayer Authority is, which prevents players from messing around with other players’ objects. By the end of the chapter, we will have a fully functional online checkers game.

Chapter 7, Developing an Online Pong Game, begins the transition from turn-based to action. Action games rely heavily on players’ reaction times, and the game world should update its state quickly to allow players to have a smooth experience. Here, we will develop an online Pong game and use the MultiplayerSynchronizer node to sync the players’ paddles and the ball. We will also learn that some features should use different syncing processes. We will go even deeper into the Multiplayer Authority realm to prevent one player’s input from interfering with the other player’s paddle’s movement. By the end of the chapter, we have a playable multiplayer online Pong game.

Chapter 8, Designing an Online Co-Op Platformer, is where our baby steps stop and we start to implement interesting features for a custom game. We will prototype a physics puzzle platformer game where players grab and move crates around to overcome obstacles and reach the level’s goal. Applying everything we’ve learned in the previous chapters, we will expand the usage of the MultiplayerSynchronizer by syncing animations on top of objects’ positions. By the end of the chapter, we will have a working prototype of a physics puzzle co-op platformer game.

Chapter 9, Creating an Online Adventure Prototype, is, if we’re honest, what you have been looking for throughout this book. Here, we will use all our skills to create an online multiplayer adventure game. Players can join and leave at any time and the world is persistent, maintaining players’ progress in quests. We will discuss the basics of making an MMORPG game, storing and retrieving players’ quest progress in a database, syncing players’ spaceships and bullets, and making their actions affect other players’ experiences. By the end of the chapter, we will have a prototype of an online multiplayer top-down space-shooter adventure game.

Chapter 10, Debugging and Profiling the Network, moves on from implementing the online multiplayer features on our top-down space-shooting adventure prototype. We now need to pave the way for thousands of players to play our game simultaneously. For that, we will use Godot Engine’s built-in debugging and profiling tools to assess the potential areas for improvements in our game. We will focus on the network profiler and the monitor debugging tools to assess and propose potential solutions for the bottlenecks we find in our prototype. By the end of the chapter, we will have two of the most powerful and necessary skills a developer can have: the ability to debug and optimize a game.

Chapter 11, Optimizing Data Requests, builds on the understanding of the tools we have at our disposal to assess the information we need to discover potential areas for improvement; now, it’s time to get our hands dirty. Throughout this chapter, we will learn how to create custom monitors to gather data about specific game features and decide the best strategy to optimize them. By the end of the chapter, we will have refactored our top-down space-shooting adventure, decreasing the bandwidth and the number of RPCs we make, effectively making our network consumption much lighter. We will have also implemented several techniques to decrease the network load, assessing each improvement with the network profiler and custom monitors to see how much better the game is becoming.

Chapter 12, Implementing Lag Compensation, deals with the issue that due to the improvements made to decrease network usage, our game may be inaccurately replicated on players’ machines. With fewer RPCs and more sparse synchronization, the game may become asynchronous among players. Add latency and packet loss on top of that and you effectively worsen the players’ experience. Nobody likes lag in their game. In this chapter, we will learn how to use Tweens to implement interpolation, prediction, and extrapolation to compensate for all these issues. By the end of the chapter, we will have a version of the top-down space-shooting adventure prototype with some fake latency and solutions for this game-breaking issue.

Chapter 13, Caching Data to Decrease Bandwidth, handles an important issue: throughout our network engineering endeavors, we have learned that bandwidth is our core resource and that we should always look to optimize its usage. In this chapter, we will learn how to use HTTP to download some data and store it on players’ machines so that we can reuse it when necessary. By the end of the chapter, we will have implemented a feature that allows players to use custom images for their spaceships, and this new image will be replicated on all other players’ instances of the game. To save bandwidth, we will implement caching using the user data folder.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image