Animate a user avatar on movement
Create your movement animations bundle
Requirements
To create an animation bundle, you'll need the Unity package Asset Bundle Browser (com.unity.assetbundlebrowser). Make sure to import it in your animation project beforehand.
1 - Rig the animated skeleton
First, you'll need a Unity avatar description to import your humanoid animations. It is best that this avatar corresponds to the one you will be using on users. You can create one and rig it from scratch or export it from an animation package.
Hierarchy Definition
For the sake of simplicity, this guide assume that your animations are rigged in a way that the avatar humanoid description is closed to the UMI3D Standard Hierarchy Definition. It is possible to use other hierarchical configuration through the use of a SkeletonMapper.
2 - Set up the movement AnimatorController
Then, create an empty Animator Controller asset. (In Project Tab, Right-click + Create/Animator Controller)
Add a blendtree (In Animator Tab, Right-click + Create State / From new blendtree) and define it as default state. (In Animator Tab, Right-click on the blend tree + Set as layer default state)
The animator controller should look like this:
Then, open the blendtree and create a animation for each of the movement animation you want to blend. Then create parameters for the parameters you want to track. Here, SPEED_X_Z will be the value of the user's speed on the (X,Z) plane.
3 - Export the bundle
Next, create an empty prefab and add an Animator component on the only GameObject node available. There, reference your emote AnimatorController.
Don't forget to toggle the option "Addressable" so that the prefab could be exported as a bundle.
Click on the "Select" button right new to the assetbundle adress bar. Then export your bundle through the assetbundle window.
You'll get a bundle file "%your-animator-name%.prefab.bundle" in the export folder. Put that file in the data folder of your UMI3D server.
Manage the user's movements animations
1 - Create an animation dispatcher
Create a new script WalkingAnimationsDispatcher with those fields:
2 - Send the skeleton animations
Regroup the two setup steps in a common method.. Send the operations within a transaction to load movement animation. The parameter will be automatically updated by the browser based on the user's movements.
Remember to clean animations when the user is leaving.Define the operation to clean the UMI3D entities.
3 - Send animations on join
Send the operation through a transaction when a user join/leave the environment.
Cannot see your animations playing?
Remember that you won't be able to see the movement animations playing if you have not bound an avatar model to the user's skeleton, because only the skeleton is animated and it is not visible. In order see it moving, refer to the guide How to bind an avatar model to a user ?.