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 5

Managing player interaction

Now that we have animated characters walking around, let’s take it one step further by learning how to interact with other players. The Multiplayer API provides several useful methods to keep track of everyone connected to the session.

Here are the main ones:

  • Multiplayer.me – returns information about the current player.
  • Multiplayer.players – provides a list of all currently joined players.
  • Multiplayer.onPlayerJoined – allows you to react when a new player joins.
  • Multiplayer.onPlayerLeft – allows you to react when a player leaves.

Let’s see how to use these APIs in action.

First, we’ll display each character’s name so others can recognize who’s who:

1character.name = Multiplayer.me.userName;
2character.nameVisible = true;

Next, let’s make it more fun by having new players greet everyone already in the session:

1let speechReg = Disposable.empty;
2
3if (!Multiplayer.players.empty) {
4    let greeting = "Hello ";
5    
6    for (let player of Multiplayer.players) {
7        greeting += ", " + player.userName;
8    }
9    
10    character.speech = greeting;
11    speechReg.dispose();
12    
13    speechReg = Time.schedule(5, () => {
14        character.speech = "";
15    });
16}

Finally, let’s make existing players greet newcomers when they join the game:

1Multiplayer.onPlayerJoined(player => {
2    character.speech = "Hello, " + player.userName;
3    speechReg.dispose();
4    
5    speechReg = Time.schedule(5, () => {
6        character.speech = "";
7    });
8});

With these simple additions, your multiplayer world becomes much more interactive, as players can now identify each other and exchange friendly greetings when joining or leaving the session. It’s a small touch that makes the experience feel alive!

Next, we’ll tidy things up by making sure characters are removed when players disconnect, preventing leftover avatars from cluttering the scene.