Controlling animations for multiplayer avatars

Hello folks,

Babylon noob here with previous experience with javascript and some very basic experience with threejs.

Quick question Im trying to tinker with a multiplayer setup with avatars. Im doing this by merging the playground avatar example (Samba girl) and the multiplayer example (Colyseus sphere example).

Im exporting the same avatar glb everytime a new session is created.

A problem I was facing is that, irrespective of the active player, the walking / dancing animation would always play for Player 1. I assume this was because animation groups are mapped to scene, and same avatar mesh means, same animation group names.

I was able to get over the problem by defining a local animation group object. The player’s sessionID is mapped to his animation group when their mesh loads.

agroup[sessionId] = animationGroups;

After doing this I was able to trigger individual animations for players, without triggering an animation for Player1

I wanted to know if this is the recommended method to implement or if their is a better way to do this?

Thanks for your help

I would be curious to have an answer also, as I have exactly the same multiplayer animation issue. I’ll do it the way you tried for the moment. Thanks

1 Like

my multi case (but i’m not use Colyseus and example)
main player is have all default set ( skin, animations, name texture … etc).
and other user clone main player
when cloned same main player values this changed of user unique set
than user have animation number of animationGruops
this mean is main player’s animationGruops[0] = walk(main player’s) , user’s animationGruops[0] = walk(user’s)
so main player(user 1) start animation[any number]
and call other user call animation this any number (seem of main player’s )
and from the standpoint of user (if user2) user play animation this any number
the result you try to compare using sessionId. It’s also a good way
case of something (user in / out , create / Remove)
Every time you increase the number of users
You will be comparing many animationGroups

@Jugernautus hi please share your playground

I didnt create a playground file. I can share the TS file if that works for you

Hello! Apologies I hadn’t seen this question, but your method sounds perfectly fine :slight_smile:

1 Like