Lets get down to business:
Apologies beforehand, as this will be a bit long winded
There are two types of Animations:
Role Animations, and Static Animations.
Static Animations are simply animations, which you may be familiar with from other worlds. Simply put it is an animation that is played back on the avatar. This is accessed using MyAvatar.overrideAnimation
Any action will not override the animation, so forexample if you dance and move, you will just keep dancing and sliding to the direction you move.
This means, it is ideal if you have a sitting animation, or “knocked back” or what ever other fun stuff you have in mind. You can restore via MyAvatar.restoreAnimation.
Role animations are animations defined as avatar-animation.json file that you load onto an Avatar. This basically defines the Animation State Machine and can be a headache to edit, but if you know what you are doing it is fantastic, but lets not dwell on that, there is an easier way:
You have two ways of replacing the animations:
Rolespecific overriding via MyAvatar.overrideRoleAnimation This is ideal if you want to allow the user to do other actions while the animation plays back. Forexample, If you want to have a limp action after an action you can
MyAvatar.overrideRoleAnimation("walkFwd", "limpUrl.fbx", 30, true, 0, 30);
To cause the avatar to play back limpUrl.fbx at 30 fps, looping, from frame 0 to 30. Blended from idle to limping every time the user walks Forward.
Which will keep until you restore the role to the state it was in avatar-animation.json
You can restore via MyAvatar.restoreRoleAnimation and MyAvatar.restoreRoleAnimations
List all available ones for your avatar via MyAvatar.getAnimationRoles
Alternatively if you want to dig in further to the avatar-animation.json:
You can permanently change the avatar-animation.json url via
Override it via
setAnimGraphUrl should be reserved to permanent changes, while
setAnimGraphOverrideUrl is for temporary changes
Further notes: on Avatar-Animation.json
All Animation Objects are defined in JSON as:
In the avatar-animation.json, these animations are usually categorized under
"type": "clip". The rest in the avatar-animation is state logic. Unfortunately the logic is a tad bit messy when presented as a json.
Note, Animations are loaded always locally, with the animation data being streamed to recievers, instead of users just sending animations to other users. This means you can simply load the avatar-animation.json and animations on local disk, with all files on your file system, but all the animations will get streamed to everyone else. However if you want to share this animation set with others, you have to upload the animations then…
Try using a
file:// prefix and the path to file to get it working and it should auto-detect changes (unless, not, inwhich you add
?<randomText> at the end of the file.
I Hope that helps