High Fidelity API Reference
Tools Used: JavaScript, JSDoc, GitHub Pages, Markdown, HTML, CSS
MyAvatar
Your avatar is your in-world representation of you. The MyAvatar API is used to manipulate the avatar. For example, you can customize the avatar's appearance, run custom avatar animations, change the avatar's position within the domain, or manage the avatar's collisions with the environment and other avatars.
Supported Script Types: Interface Scripts • Client Entity Scripts • Avatar Scripts
Properties
| Name | Type | Summary |
|---|---|---|
position | The position of the avatar. | |
scale | number | The scale of the avatar. The value can be set to anything between Default Value: 1.0 |
density | number | The density of the avatar in kg/m3. The density is used to work out its mass in the application of physics. Read-only. |
handPosition | A user-defined hand position, in world coordinates. The position moves with the avatar but is otherwise not used or changed by Interface. | |
orientation | The orientation of the avatar. | |
headOrientation | The orientation of the avatar's head. | |
headPitch | number | The rotation about an axis running from ear to ear of the avatar's head. Pitch is sometimes called "elevation". |
headYaw | number | The rotation left or right about an axis running from the base to the crown of the avatar's head. Yaw is sometimes called "heading". |
headRoll | number | The rotation about an axis running from the nose to the back of the avatar's head. Roll is sometimes called "bank". |
velocity | The current velocity of the avatar. | |
displayName | string | The avatar's display name. |
sessionDisplayName | string |
|
attachmentData | Array.<AttachmentData> | Information on the avatar's attachments. Deprecated: This property is deprecated and will be removed. Use avatar entities instead. |
jointNames | Array.<string> | The list of joints in the current avatar model. Read-only. |
sessionUUID | Unique ID of the avatar in the domain. Read-only. | |
leftHandPosition | The position of the left hand in avatar coordinates if it's being positioned by controllers, otherwise Vec3.ZERO. Read-only. | |
rightHandPosition | The position of the right hand in avatar coordinates if it's being positioned by controllers, otherwise Vec3.ZERO. Read-only. | |
collisionsEnabled | boolean | Set to |
userHeight | number | The height of the user in sensor space. Default Value: 1.75 |
walkBackwardSpeed | number | The walk backward speed of your avatar. |
sprintSpeed | number | The sprint (run) speed of your avatar. |
isInSittingState | number |
|
Methods
| Name | Return Value | Summary |
|---|---|---|
None | Attaches a model to your avatar. For example, you can give your avatar a hat to wear, a guitar to hold, or a surfboard to stand on. Deprecated: This function is deprecated and will be removed. Use avatar entities instead. | |
None | Starts a sitting action for the avatar. | |
None | Moves and orients the avatar, such that it is directly underneath the HMD, with toes pointed forward in the direction of the HMD. | |
None | Clears joint translations and rotations set by script for a specific joint. This restores all motion from the default animation system including inverse kinematics for that joint. | |
None | Ends a sitting action for the avatar. | |
Gets the current acceleration of the avatar. | ||
number | Gets the target scale of the avatar. The target scale is the desired scale of the avatar without any restrictions on permissible scale values imposed by the domain. | |
number | Sets the amount of gravity applied to the avatar in the y-axis direction. (Negative values are downward.) The default value is | |
number | Gets the current height of the avatar. This height is only an estimate and might be incorrect for avatars that are missing standard joints. | |
number | Gets the joint index for a named joint. The joint index value is the position of the joint in the array returned by MyAvatar.getJointNames. | |
Array.<string> | Gets the names of all the joints in the current avatar. | |
Gets the position of a joint in the current avatar. | ||
Gets the rotation of a joint relative to its parent. | ||
Gets the translation of a joint relative to its parent, in model coordinates. Warning: These coordinates are not necessarily in meters. | ||
Gets the ID of the entity of avatar that the avatar is parented to. | ||
Array.<MyAvatar.SkeletonJoint> | Gets information on all the joints in the avatar's skeleton. | |
None | Moves the avatar to a new position and (optional) orientation in the domain. | |
Creates a new grab that grabs an entity. | ||
None | Increases the avatar's scale by five percent, up to a minimum scale of | |
boolean | Checks whether your avatar is flying. | |
boolean | Checks whether your avatar is in the air. | |
boolean | Gets whether the avatar is in a seated pose. The seated pose is set by calling the MyAvatar::beginSit method. | |
None | Overrides the default avatar animations. | |
boolean | Sets and locks a joint's position and orientation. Note: Only works on the hips joint. | |
None | Releases (deletes) a grab to stop grabbing an entity. | |
None | Resets the avatar's scale back to the default scale of | |
None | Restores the default animations. | |
None | Sets the target scale of the avatar. The target scale is the desired scale of the avatar without any restrictions on permissible scale values imposed by the domain. | |
None | Sets the amount of gravity applied to the avatar in the y-axis direction. (Negative values are downward.) | |
None | Sets a specific joint's rotation and position relative to its parent, in model coordinates. Warning: These coordinates are not necessarily in meters. | |
None | Sets a specific joint's rotation relative to its parent. | |
None | Sets a specific joint's translation relative to its parent, in model coordinates. Warning: These coordinates are not necessarily in meters. | |
None | Sets the ID of the entity of avatar that the avatar is parented to. | |
None | Deprecated: This function is deprecated and will be removed. | |
None | Enables and disables flow simulation of physics on the avatar's hair, clothes, and body parts. |
Signals
| Name | Summary |
|---|---|
Triggered when the a model is attached to or detached from one of the avatar's joints using one of attach or setAttachmentData. Deprecated: This signal is deprecated and will be removed. Use avatar entities instead. | |
Triggered when collisions with the environment are enabled or disabled. | |
Triggered when the avatar collides with an entity. | |
Triggered when the avatar's | |
Triggered when the avatar's model finishes loading. | |
Triggered when the avatar's model has failed to load. | |
Triggered when the avatar has been moved to a new position by one of the MyAvatar "goTo" functions. | |
Triggered when the avatar's size changes. This can be due to the user changing the size of their avatar or the domain limiting the size of their avatar. | |
Triggered when the avatar's | |
Triggered when the avatar's | |
Triggered when the avatar's model is changed. | |
Triggered when the sprint (run) speed set changes. | |
Triggered when the walk backward speed set changes. | |
Triggered when your avatar changes from being away to being active. | |
Triggered when your avatar changes from being active to being away. |
Type Definitions
AvatarEntityDataAvatarEntityData Type: object | |||||||||
|---|---|---|---|---|---|---|---|---|---|
Information about an avatar entity. Properties
|
FlowDataFlowData Type: object | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Flow options currently used in flow simulation. Properties
|
FlowPhysicsDataFlowPhysicsData Type: object | |||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A set of physics options currently used in flow simulation. Properties
|
GoToPropertiesGoToProperties Type: object | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
A teleport target. Properties
|
LocomotionControlsModeLocomotionControlsMode Type: number | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
Locomotion control types. Properties
|
SitStandModelTypeSitStandModelType Type: number | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
Specifies different avatar leaning and recentering behaviors. Properties
|
SkeletonJointSkeletonJoint Type: object | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
Information about a single joint in an avatar's skeleton hierarchy. Properties
|
Method Details
attach(static) attach( modelURL, jointNameopt, translationopt, rotationopt, scaleopt, |
|---|
Attaches a model to your avatar. For example, you can give your avatar a hat to wear, a guitar to hold, or a surfboard to stand on. Deprecated: This function is deprecated and will be removed. Use avatar entities instead. |
beginSit(static) beginSit( position, rotation ) | |||||||||
|---|---|---|---|---|---|---|---|---|---|
Starts a sitting action for the avatar. Parameters
|
centerBody(static) centerBody( ) |
|---|
Moves and orients the avatar, such that it is directly underneath the HMD, with toes pointed forward in the direction of the HMD. |
clearJointData(static) clearJointData( name ) | ||||||
|---|---|---|---|---|---|---|
Clears joint translations and rotations set by script for a specific joint. This restores all motion from the default animation system including inverse kinematics for that joint. Note: This is slightly slower than the function variation that specifies the joint index. Parameters
Example: Offset and restore the position of your avatar's head |
endSit(static) endSit( position, rotation ) | |||||||||
|---|---|---|---|---|---|---|---|---|---|
Ends a sitting action for the avatar. Parameters
|
getAcceleration(static) getAcceleration( ) → { Vec3 } Returns: The current acceleration of the avatar. |
|---|
Gets the current acceleration of the avatar. |
getAvatarScale(static) getAvatarScale( ) → { number } Returns: The target scale for the avatar, range |
|---|
Gets the target scale of the avatar. The target scale is the desired scale of the avatar without any restrictions on permissible scale values imposed by the domain. |
getGravity(static) getGravity( ) → { number } Returns: The amount of gravity currently applied to the avatar, in m/s2. |
|---|
Sets the amount of gravity applied to the avatar in the y-axis direction. (Negative values are downward.) The default value is |
getHeight(static) getHeight( ) → { number } Returns: The height of the avatar. |
|---|
Gets the current height of the avatar. This height is only an estimate and might be incorrect for avatars that are missing standard joints. |
getJointIndex(static) getJointIndex( name ) → { number } Returns: The index of the joint if valid, otherwise -1. | ||||||
|---|---|---|---|---|---|---|
Gets the joint index for a named joint. The joint index value is the position of the joint in the array returned by MyAvatar.getJointNames. Parameters
Example: Report the index of your avatar's left arm joint |
getJointNames(static) getJointNames( ) → { Array.<string> } Returns: The joint names. |
|---|
Gets the names of all the joints in the current avatar. Example: Report the names of all the joints in your current avatar |
getJointPosition(static) getJointPosition( name ) → { Vec3 } Returns: The position of the joint in world coordinates. | ||||||
|---|---|---|---|---|---|---|
Gets the position of a joint in the current avatar. Parameters
Example: Report the position of your avatar's hips |
getJointRotation(static) getJointRotation( name ) → { Quat } Returns: The rotation of the joint in world coordinates. | ||||||
|---|---|---|---|---|---|---|
Gets the rotation of a joint relative to its parent. Parameters
Example: Report the rotation of your avatar's hips joint |
getJointTranslation(static) getJointTranslation( name ) → { Vec3 } Returns: The translation of the joint relative to its parent, in model coordinates. | ||||||
|---|---|---|---|---|---|---|
Gets the translation of a joint relative to its parent, in model coordinates. Warning: These coordinates are not necessarily in meters. Parameters
Example: Report the translation of your avatar's hips joint |
getParentID(static) getParentID( ) → { Uuid } Returns: The ID of the entity or avatar that the avatar is parented to; if not parented, returns Uuid.NULL. |
|---|
Gets the ID of the entity of avatar that the avatar is parented to. |
getSkeleton(static) getSkeleton( ) → { Array.<MyAvatar.SkeletonJoint> } Returns: Information about each joint in the avatar's skeleton. |
|---|
Gets information on all the joints in the avatar's skeleton. |
goToLocation(static) goToLocation( position, hasOrientationopt, orientationopt, | |||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Moves the avatar to a new position and/or orientation in the domain. Parameters
|
grab(static) grab( targetID, parentJointIndex, offset, rotationalOffset ) → { Uuid } Returns: The ID of the new grab. | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Creates a new grab that grabs an entity. Parameters
Example: Create and grab an entity for a short while |
increaseSize(static) increaseSize( ) |
|---|
Increases the avatar's scale by five percent, up to a minimum scale of Example: Reset your avatar's size to default then grow it 5 times |
isFlying(static) isFlying( ) → { boolean } Returns: |
|---|
Checks whether your avatar is flying. |
isInAir(static) isInAir( ) → { boolean } Returns: |
|---|
Checks whether your avatar is in the air. |
isSeated(static) isSeated( ) → { boolean } Returns: |
|---|
Gets whether the avatar is in a seated pose. The seated pose is set by calling the MyAvatar.beginSit method. |
overrideAnimation(static) overrideAnimation( url, fps, loop, firstFrame, lastFrame ) | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Overrides the default avatar animations. The avatar animation system includes a set of default animations along with rules for how those animations are blended together with procedural data (such as look at vectors, hand sensors etc.). Note: When using pre-built animation data, it's critical that the joint orientation of the source animation and target rig are equivalent, since the animation data applies absolute values onto the joints. If the orientations are different, the avatar will move in unpredictable ways. Parameters
Example: Play a clapping animation on your avatar for three seconds |
pinJoint(static) pinJoint( index, position, orientation ) → { boolean } Returns: | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
Sets and locks a joint's position and orientation. Note: Only works on the hips joint. Parameters
|
releaseGrab(static) releaseGrab( grabID ) | ||||||
|---|---|---|---|---|---|---|
Releases (deletes) a grab to stop grabbing an entity. Parameters
|
resetSize(static) resetSize( ) |
|---|
Resets the avatar's scale back to the default scale of |
restoreAnimation(static) restoreAnimation( ) |
|---|
Restores the default animations. The avatar animation system includes a set of default animations along with rules for how those animations are blended together with procedural data (such as look at vectors, hand sensors etc.). Playing your own custom animations will override the default animations. Example: Play a clapping animation on your avatar for three seconds |
setAvatarScale(static) setAvatarScale( scale ) | ||||||
|---|---|---|---|---|---|---|
Sets the target scale of the avatar. The target scale is the desired scale of the avatar without any restrictions on permissible scale values imposed by the domain. Parameters
|
setGravity(static) setGravity( gravity ) | ||||||
|---|---|---|---|---|---|---|
Sets the amount of gravity applied to the avatar in the y-axis direction. (Negative values are downward.) Parameters
|
setJointData(static) setJointData( name, rotation, translation ) | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
Sets a specific joint's rotation and position relative to its parent, in model coordinates. Warning: These coordinates are not necessarily in meters. Setting joint data completely overrides/replaces all motion from the default animation system including inverse kinematics, but just for the specified joint. So for example, if you were to procedurally manipulate the finger joints, the avatar's hand and head would still do inverse kinematics properly. However, as soon as you start to manipulate joints in the inverse kinematics chain, the inverse kinematics might not function as you expect. For example, if you set the rotation of the elbow, the hand inverse kinematics position won't end up in the right place. Parameters
|
setJointRotation(static) setJointRotation( name, rotation ) | |||||||||
|---|---|---|---|---|---|---|---|---|---|
Sets a specific joint's rotation relative to its parent. Setting joint data completely overrides/replaces all motion from the default animation system including inverse kinematics, but just for the specified joint. So for example, if you were to procedurally manipulate the finger joints, the avatar's hand and head would still do inverse kinematics properly. However, as soon as you start to manipulate joints in the inverse kinematics chain, the inverse kinematics might not function as you expect. For example, if you set the rotation of the elbow, the hand inverse kinematics position won't end up in the right place. Parameters
|
setJointTranslation(static) setJointTranslation( name, translation ) | |||||||||
|---|---|---|---|---|---|---|---|---|---|
Sets a specific joint's translation relative to its parent, in model coordinates. Warning: These coordinates are not necessarily in meters. Setting joint data completely overrides/replaces all motion from the default animation system including inverse kinematics, but just for the specified joint. So for example, if you were to procedurally manipulate the finger joints, the avatar's hand and head would still do inverse kinematics properly. However, as soon as you start to manipulate joints in the inverse kinematics chain, the inverse kinematics might not function as you expect. For example, if you set the rotation of the elbow, the hand inverse kinematics position won't end up in the right place. Parameters
Example: Stretch your avatar's neckDepending on the avatar you are using, you will either see a gap between the head and body or you will see the neck stretched |
setParentID(static) setParentID( parentID ) | ||||||
|---|---|---|---|---|---|---|
Sets the ID of the entity of avatar that the avatar is parented to. Parameters
|
setSessionUUID(static) setSessionUUID( sessionUUID ) |
|---|
Deprecated: This function is deprecated and will be removed. |
useFlow(static) useFlow( isActive, isCollidable, physicsConfigopt, collisionsConfigopt ) | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
Enables and disables flow simulation of physics on the avatar's hair, clothes, and body parts. Parameters
|
Signal Details
attachmentsChangedattachmentsChanged( ) Returns: Signal |
|---|
Triggered when the a model is attached to or detached from one of the avatar's joints using attach or setAttachmentData. Deprecated: This signal is deprecated and will be removed. Use avatar entities instead. |
collisionsEnabledChangedcollisionsEnabledChanged( enabled ) Returns: Signal | ||||||
|---|---|---|---|---|---|---|
Triggered when collisions with the environment are enabled or disabled. Parameters
|
collisionWithEntitycollisionWithEntity( collision ) Returns: Signal | ||||||
|---|---|---|---|---|---|---|
Triggered when the avatar collides with an entity. Parameters
Example: Report each time your avatar collides with an entity |
displayNameChangeddisplayNameChanged( ) Returns: Signal |
|---|
Triggered when the avatar's Example: Report when your avatar display name changes |
onLoadCompleteonLoadComplete( ) Returns: Signal |
|---|
Triggered when the avatar's model finishes loading. |
onLoadFailedonLoadFailed( ) Returns: Signal |
|---|
Triggered when the avatar's model has failed to load. |
positionGoneTopositionGoneTo( ) Returns: Signal |
|---|
Triggered when the avatar has been moved to a new position by one of the MyAvatar "goTo" functions. |
scaleChangedscaleChanged( ) Returns: Signal |
|---|
Triggered when the avatar's size changes. This can be due to the user changing the size of their avatar or the domain limiting the size of their avatar. |
sessionDisplayNameChangedsessionDisplayNameChanged( ) Returns: Signal |
|---|
Triggered when the avatar's Example: Report when your avatar's session display name changes |
sessionUUIDChangedsessionUUIDChanged( ) Returns: Signal |
|---|
Triggered when the avatar's Example: Report when your avatar's session UUID changes |
skeletonChangedskeletonChanged( ) Returns: Signal |
|---|
Triggered when the avatar's model (i.e., |
sprintSpeedChangedsprintSpeedChanged( speed ) Returns: Signal | ||||||
|---|---|---|---|---|---|---|
Triggered when the sprint (run) speed set changes. Parameters
|
walkBackwardSpeedChangedwalkBackwardSpeedChanged( speed ) Returns: Signal | ||||||
|---|---|---|---|---|---|---|
Triggered when the walk backward speed set changes. Parameters
|
wentActivewentActive( ) Returns: Signal |
|---|
Triggered when your avatar changes from being away to being active. |
wentAwaywentAway( ) Returns: Signal |
|---|
Triggered when your avatar changes from being active to being away. Example: Report when your avatar goes away |