Cookies
information
We use cookies to learn how you interact with this website and analyze this information. Please accept this before browsing further.
If you decline, we won't collect any information when you visit this website.
View our Data Privacy Statement for more information.
Cookies
preferences
Essential
Cookies that are necessary for the website to function properly. They enable core features such as security, network management, and accessibility.
Marketing
Cookies used to track visitors across websites to display relevant ads and marketing campaigns based on user behavior.
Analytics
Cookies that help us understand how visitors interact with the website by collecting and reporting information anonymously.
View our Data Privacy Statement for more information.

Creating a multiplayer Experience in Delightex Nova

Delightex Nova allows you to collaborate and play together with others through its multiplayer Experiences.

In this tutorial, you’ll learn how to create and explore your first multiplayer session step by step.

Part 6

Removing unused characters

Our current game has one small issue: when a player leaves the session, their character stays behind in the scene. Let’s fix that by cleaning up unused avatars when players disconnect.

To start, remember that a player cannot remove their own character. In most multiplayer systems, the Host serves as the authority, and we’ll follow that same approach here.

Now, the Host needs to know which character belongs to which player. To do that, we’ll use custom properties. These are automatically synchronized between all players and are perfect for passing simple information, like IDs.

Here’s how it works:

First, when a player creates their character, they attach their unique player identifier to the item using a custom property:

1character.setProperty("playerId", Multiplayer.me.id);

Second, the Host listens for the “player left” event and removes any characters belonging to the disconnected player:

1if (Multiplayer.isHost) {
2    Multiplayer.onPlayerLeft(player => {
3        for (let item of Scene.items.copy()) {
4            if (item.getProperty("playerId") === player.id) {
5                item.delete();
6            }
7        }
8    });
9}

This ensures that whenever someone leaves the game (whether intentionally or because of a crash), their avatar is automatically removed from the scene. The result? A cleaner, more reliable multiplayer Experience that stays synchronized for everyone!

In the next lesson, we’ll use custom properties to introduce NPCs that behave consistently for every player, allowing you to create shared logic and more dynamic multiplayer interactions.