Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
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

Product type Book
Published in Dec 2023
Publisher Packt
ISBN-13 9781803232614
Pages 326 pages
Edition 1st Edition
Languages
Author (1):
Henrique Campos Henrique Campos
Profile icon Henrique Campos

Table of Contents (19) Chapters

Preface 1. Part 1:Handshaking and Networking
2. Chapter 1: Setting up a Server 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

Creating an Online Co-Op Platformer Prototype

In this chapter, we will delve deeper into the work of creating action multiplayer online games. Our goal is to turn a local multiplayer puzzle platformer game prototype into an online version.

Here’s what the final puzzle platformer prototype will look like:

Figure 8.1 – A preview of the Puzzle Platformer prototype

Figure 8.1 – A preview of the Puzzle Platformer prototype

By the end of this chapter, you’ll know how to use the features of the MultiplayerSpawner node to create and assign playable characters to each player in the game, using the features offered by MultiplayerSynchronizer to sync relevant properties. With these features, we can go beyond updating the position of nodes; they will allow us to synchronize other properties, particularly animations. You will also learn how to leverage Remote Procedure Calls (RPCs) to manipulate the multiplayer authority of nodes. This will enable us to implement an exciting object-grabbing mechanic...

Technical requirements

To access the resources for this chapter, you can find our repository of online projects by following the link provided here: https://github.com/PacktPublishing/The-Essential-Guide-to-Creating-Multiplayer-Games-with-Godot-4.0.

Once you have the repository, open the res://08.designing-online-platformer folder in the Godot Engine editor. All the necessary files for this chapter are located there.

Now, let’s begin the onboarding process. In the upcoming section, we will familiarize ourselves with the project, explore its main classes, and identify where we need to implement networking features.

Introducing the platformer project

Our project presents a captivating puzzle platformer that will test players’ strategic thinking and collaboration skills as they overcome challenging obstacles together. At the heart of this game lies a core mechanic centered around the manipulation of objects, utilizing them to construct platforms for the other player to traverse.

Now, let’s dive into the essential classes that serve as the pillars of our project’s foundation. Our first encounter will be with the Player class, which embodies the avatars controlled by each individual player. As the main protagonist, the Player class handles essential functionalities such as movement and interaction with various environmental elements. Notably, the Player class incorporates InteractionArea2D that detects contact with InteractiveArea2D, enabling players to perform specific actions upon them.

Moving forward, we encounter the InteractiveArea2D class. This class extends the functionality...

Spawning players in the match

In this section, we will understand how to improve the PlayerSpawner class to introduce online multiplayer features to our game. Leveraging the foundation laid by the Understanding the PlayerSpawner class, Unveiling the Crate class, and the Understanding the Player class sections, these enhancements enable multiple players to connect and interact seamlessly within a synchronized game environment.

PlayerSpawner node plays a fundamental role in our game’s multiplayer architecture, acting as the core mechanism responsible for dynamically creating instances of the Player class for each connected player. These instances represent the avatars through which players engage with the game world.

With the integration of multiplayer functionalities, we will add features designed for an online multiplayer experience. This includes mechanisms to handle multiplayer authority, enabling proper gameplay across all connected peers. On top of that, the code will...

Syncing physical objects

In this section, we will understand how to use the MultiplayerSynchronizer node for more than position updates. This node plays an important role in ensuring that players are synchronized with the avatars of other players in the game. As we have seen in the Giving players control in PlayerSpawner section, it is essential to maintain consistency among players to create a seamless multiplayer experience.

The MultiplayerSynchronizer class serves as a bridge between players, enabling real-time updates and synchronization of various properties. One key aspect that we will explore is how the Crate object’s position is updated based on the player who is carrying it. This functionality allows for interactive and collaborative gameplay, where players can work together to solve puzzles or accomplish tasks.

On top of that, we will see how the MultiplayerSynchronizer node handles properties related to avatar animations. By leveraging the MultiplayerSynchronizer...

Summary

In this chapter, we dived into the world of online multiplayer puzzle platformers, which emphasized teamwork and collaboration. Players will be challenged to work together, leveraging their skills to overcome obstacles and progress through intricate levels. Throughout the chapter, we explored key concepts and techniques to enhance the multiplayer experience and create a seamless collaborative gameplay environment.

To enable multiplayer functionality, we introduced the MultiplayerSpawner class, which dynamically instantiates Player instances based on the number of connected players. This ensures that each player has a unique avatar in the game, promoting a personalized and immersive multiplayer experience. The Player class played a crucial role, and we implemented the setup_multiplayer() method to configure its multiplayer settings. This method allowed us to set each instance’s multiplayer authority, adjust physics and input processing, and update a visual player index...

lock icon The rest of the chapter is locked
You have been reading a chapter from
The Essential Guide to Creating Multiplayer Games with Godot 4.0
Published in: Dec 2023 Publisher: Packt ISBN-13: 9781803232614
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 €14.99/month. Cancel anytime}