Log inGet started
Package

AvatarAnimator.component

Newest version

This package holds more than this page lists. See all of its files in its world.

README.md

AvatarAnimator

Runs an avatar's declared parameters, animator, expression menu and parts (the parameters, animator, menu and parts of its avatar.json, see modules.avatarAnimator) on the avatar root. An avatar that declares any of them gets this component when it is instantiated, on every peer, and each peer seats its own copy of the avatar's parts on the body.

The peer that owns the avatar holds its parameters: the Expressions tab of the app menu, a game or the avatar's own components set them, and the synced ones reach every other peer on the avatar channel within one parameter send interval (a tenth of a second); a peer that joins later receives the current block at once. Every peer evaluates the same animator from the same parameters and applies it to its own copy of the body: blend shapes, bone offsets added over the locomotion playing, the clips its states play (each under its layer's mask and weight, over the locomotion), the parts it shows and hides and the shader data lanes of its meshes. It evaluates on the session clock and dates each state by the parameters the channel dates, so a remote peer plays a gesture clip at the point the owner plays it. A body no other animator drives gets a graph of this component's own for its clips.

local anim = layers.active.players.localPlayer.avatar.component.get("AvatarAnimator")
anim:set("Hat", false)              -- every peer hides the hat
anim:set("EarAngle", 0.6)
print(anim:get("Speed"), anim:get("Voice"))
anim:emote(3)                       -- `Emote` reads 3 on every peer, `EmoteTime` how long since
print(anim:stats().cost.units, anim:stats().evaluationMs)
  • avatar (synced): the avatar asset whose definition it runs.
  • :set(name, value) on the owner; :get(name), :values(), :parameters(), :menu(), :layers() (each layer's state, time, enteredAt on the session clock, blend, weight and the clips it plays with each one's time), :emote(id) (an emote multiplayer.avatarEmote starts on the avatar's channel reads the same), :stats() (cost, evaluationMs, syncedBits, channel, owned, readsVoice, clips with whether each is bound and its length or failure, failure).

A saved parameter is written into the avatar's appearance document, and one the person sets themselves from the Expressions tab is also kept on their device for this avatar (a value a script sets is never written to the person's device). The avatar starts with the document's values and then the device's, and reads the document again whenever the avatar wears another.

Location: src/lua/lib/components/AvatarAnimator.component