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 4

Adding animations

Now that players can see each other, things already look more exciting, but our characters are still floating motionless above the ground. Let’s bring them to life with some simple animation.

To make characters move more naturally, we’ll use Time.scheduleRepeating again to check the player’s position every frame. Here’s the basic idea:

1. Track movement: Save the character’s position from the previous frame, then compare it with the current position.

  • If the position has changed, the character is moving.
  • If it hasn’t, the character is idle.

2. Update animation only when state changes: Keep track of whether the character was moving in the last frame. If the movement state changes (for example, from idle to moving or vice versa), update the animation accordingly. This keeps things efficient and prevents unnecessary animation restarts.

Before coding the animation logic, make sure the character variable is cast to the correct type. By default, copy returns a BaseItem, but for animations you need it as an AnimatedItem. So, update the line that creates the characters to something like this:

1let character = characterProto.copy() as AnimatedItem;

So the code snippet looks like this:

1let wasMoving = false;
2let lastX = cameraItem.transform.position.x;
3let lastY = cameraItem.transform.position.y;
4
5Time.scheduleRepeating(() => {
6    let newPos = cameraItem.transform.position;
7    let moving = false;
8    if (newPos.x != lastX || newPos.y != lastY) {
9        lastX = newPos.x;
10        lastY = newPos.y;
11        moving = true;
12    }
13    if (wasMoving != moving) {
14        wasMoving = moving;
15        if (moving) {
16            character.animation.playLooping("Walk");
17        } else {
18            character.animation.playLooping("Neutral");
19        }
20    }
21});

Now you can play this Experience and see that the characters display a “walking” animation whenever they move around the scene.
With this setup, your avatars will seamlessly switch between idle and walking animations as players move around, adding that extra touch of life to your multiplayer Experience!

In the next lesson, we’ll look at how to handle player interactions by tracking who joins and leaves the session and responding to these events using the Multiplayer API.