MyAvatar

Description

Supported Script Types: Interface Scripts • Client Entity Scripts • Avatar Scripts

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.

For assignment client scripts, see Avatar.

Properties

Name Type Summary
position Vec3

The position of the avatar.

scale number

The scale of the avatar. The value can be set to anything between 0.005 and 1000.0. When the scale value is fetched, it may temporarily be further limited by the domain's settings.

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 Vec3

A user-defined hand position, in world coordinates. The position moves with the avatar but is otherwise not used or changed by Interface.

bodyYaw number

The left or right rotation about an axis running from the head to the feet of the avatar. Yaw is sometimes called "heading".

bodyPitch number

The rotation about an axis running from shoulder to shoulder of the avatar. Pitch is sometimes called "elevation".

bodyRoll number

The rotation about an axis running from the chest to the back of the avatar. Roll is sometimes called "bank".

orientation Quat

The orientation of the avatar.

headOrientation Quat

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 Vec3

The current velocity of the avatar.

angularVelocity Vec3

The current angular velocity of the avatar.

audioLoudness number

The instantaneous loudness of the audio input that the avatar is injecting into the domain.

audioAverageLoudness number

The rolling average loudness of the audio input that the avatar is injecting into the domain.

displayName string

The avatar's display name.

sessionDisplayName string

displayName's sanitized and default version defined by the avatar mixer rather than Interface clients. The result is unique among all avatars present in the domain at the time.

lookAtSnappingEnabled boolean

true if the avatar's eyes snap to look at another avatar's eyes when the other avatar is in the line of sight and also has lookAtSnappingEnabled == true.

Default Value: true

skeletonModelURL string

The avatar's FST file.

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 Uuid

Unique ID of the avatar in the domain. Read-only.

sensorToWorldMatrix Mat4

The scale, rotation, and translation transform from the user's real world to the avatar's size, orientation, and position in the virtual world. Read-only.

controllerLeftHandMatrix Mat4

The rotation and translation of the left hand controller relative to the avatar. Read-only.

controllerRightHandMatrix Mat4

The rotation and translation of the right hand controller relative to the avatar. Read-only.

sensorToWorldScale number

The scale that transforms dimensions in the user's real world to the avatar's size in the virtual world. Read-only.

hasPriority boolean

true if the avatar is in a "hero" zone, false if it isn't. Read-only.

hasScriptedBlendshapes boolean

true if blend shapes are controlled by scripted actions, otherwise false. Set this to true before using the MyAvatar.setBlendshape method, and set back to false after you no longer want scripted control over the blend shapes.

Note: This property will automatically be set to true if the controller system has valid facial blend shape actions.

Default Value: false

hasProceduralBlinkFaceMovement boolean

true if avatars blink automatically by animating facial blend shapes, false if automatic blinking is disabled. Set to false to fully control the blink facial blend shapes via the MyAvatar.setBlendshape method.

Default Value: true

hasProceduralEyeFaceMovement boolean

true if the facial blend shapes for an avatar's eyes adjust automatically as the eyes move, false if this automatic movement is disabled. Set this property to true to prevent the iris from being obscured by the upper or lower lids. Set to false to fully control the eye blend shapes via the MyAvatar.setBlendshape method.

Default Value: true

hasAudioEnabledFaceMovement boolean

true if the avatar's mouth blend shapes animate automatically based on detected microphone input, false if this automatic movement is disabled. Set this property to false to fully control the mouth facial blend shapes via the MyAvatar.setBlendshape method.

Default Value: true

skeletonOffset Vec3

Can be used to apply a translation offset between the avatar's position and the registration point of the 3D model.

qmlPosition Vec3

A synonym for position for use by QML.

Deprecated: This property is deprecated and will be removed.

feetPosition Vec3

The position of the avatar's feet.

shouldRenderLocally boolean

If true then your avatar is rendered for you in Interface, otherwise it is not rendered for you (but it is still rendered for other users).

Default Value: true

motorVelocity Vec3

The target velocity of your avatar to be achieved by a scripted motor.

Default Value: Vec3.ZERO

motorTimescale number

The timescale for the scripted motor to achieve the target motorVelocity avatar velocity. Smaller values result in higher acceleration.

Default Value: 1000000

motorReferenceFrame string

Reference frame of the motorVelocity. Must be one of the following: "camera", "avatar", and "world".

Default Value: "camera"

motorMode string

The Type of scripted motor behavior: "simple" to use the motorTimescale time scale; "dynamic" to use character controller timescales.

Default Value: "simple"

collisionSoundURL string

The sound that's played when the avatar experiences a collision. It can be a mono or stereo 16-bit WAV file running at either 24kHz or 48kHz. The latter is down-sampled by the audio mixer, so all audio effectively plays back at a 24khz. 48kHz RAW files are also supported.

Default Value: "Body_Hits_Impact.wav"

audioListenerMode number

Specifies the listening position when hearing spatialized audio. Must be one of the following property values:

  • MyAvatar.audioListenerModeHead
  • MyAvatar.audioListenerModeCamera
  • MyAvatar.audioListenerModeCustom

Default Value: 0

audioListenerModeHead number

The audio listening position is at the avatar's head. Read-only.

Default Value: 0

audioListenerModeCamera number

The audio listening position is at the camera. Read-only.

Default Value: 1

audioListenerModeCustom number

The audio listening position is at a the position specified by set by the customListenPosition and customListenOrientation property values. Read-only.

Default Value: 2

customListenPosition Vec3

The listening position used when the audioListenerMode property value is audioListenerModeCustom.

Default Value: Vec3.ZERO

customListenOrientation Quat

The listening orientation used when the audioListenerMode property value is audioListenerModeCustom.

Default Value: Quat.IDENTITY

rotationRecenterFilterLength number

Configures how quickly the avatar root rotates to recenter its facing direction to match that of the user's torso based on head and hands orientation. A smaller value makes the recentering happen more quickly. The minimum value is 0.01.

rotationThreshold number

The angle in radians that the user's torso facing direction (based on head and hands orientation) can differ from that of the avatar before the avatar's root is rotated to match the user's torso.

enableStepResetRotation boolean

If true then after the user's avatar takes a step, the avatar's root immediately rotates to recenter its facing direction to match that of the user's torso based on head and hands orientation.

enableDrawAverageFacing boolean

If true, debug graphics are drawn that show the average facing direction of the user's torso (based on head and hands orientation). This can be useful if you want to try out different filter lengths and thresholds.

leftHandPosition Vec3

The position of the left hand in avatar coordinates if it's being positioned by controllers, otherwise Vec3.ZERO. Read-only.

rightHandPosition Vec3

The position of the right hand in avatar coordinates if it's being positioned by controllers, otherwise Vec3.ZERO. Read-only.

leftHandTipPosition Vec3

The position 0.3m in front of the left hand's position, in the direction along the palm, in avatar coordinates. If the hand isn't being positioned by a controller, the value is Vec3.ZERO. Read-only.

rightHandTipPosition Vec3

The position 0.3m in front of the right hand's position, in the direction along the palm, in avatar coordinates. If the hand isn't being positioned by a controller, the value is Vec3.ZERO. Read-only.

leftHandPose Pose

The left hand's pose as determined by the hand controllers, relative to the avatar. Read-only.

rightHandPose Pose

The right hand's pose as determined by the hand controllers, relative to the avatar. Read-only.

leftHandTipPose Pose

The left hand's pose as determined by the hand controllers, relative to the avatar, with the position adjusted by 0.3m along the direction of the palm. Read-only.

rightHandTipPose Pose

The right hand's pose as determined by the hand controllers, relative to the avatar, with the position adjusted by 0.3m along the direction of the palm. Read-only.

energy number

Deprecated: This property will be removed.

isAway boolean

true if your avatar is away (i.e., inactive), false if it is active.

centerOfGravityModelEnabled boolean

true if the avatar hips are placed according to the center of gravity model that balances the center of gravity over the base of support of the feet. Set the value to false for default behavior where the hips are positioned under the head.

Default Value: true

hmdLeanRecenterEnabled boolean

true IF the avatar is re-centered to be under the head's position. In room-scale VR, this behavior is what causes your avatar to follow your HMD as you walk around the room. Setting the value false is useful if you want to pin the avatar to a fixed position.

Default Value: true

collisionsEnabled boolean

Set to true to enable the avatar to collide with the environment, false to disable collisions with the environment. May return true even though the value was set false because the zone may disallow collisionless avatars.

otherAvatarsCollisionsEnabled boolean

Set to true to enable the avatar to collide with other avatars, false to disable collisions with other avatars.

characterControllerEnabled boolean

Synonym of collisionsEnabled.

Deprecated: This property is deprecated and will be removed. Use collisionsEnabled instead.

useAdvancedMovementControls boolean

Returns and sets the value of the Interface setting, Settings > Controls > Walking. Note: Setting the value has no effect unless Interface is restarted.

showPlayArea boolean

Returns and sets the value of the Interface setting, Settings > Controls > Show room boundaries while teleporting.

Note: Setting the value has no effect unless Interface is restarted.

yawSpeed number

The mouse X sensitivity value in Settings > General. Read-only.

Default Value: 75

pitchSpeed number

The mouse Y sensitivity value in Settings > General. Read-only.

Default Value: 50

hmdRollControlEnabled boolean

If true, the roll angle of your HMD turns your avatar while flying.

Default Value: true

hmdRollControlDeadZone number

The amount of HMD roll, in degrees, required before your avatar turns if hmdRollControlEnabled is enabled.

Default Value: 8

hmdRollControlRate number

If MyAvatar.hmdRollControlEnabled is true, this value determines the maximum turn rate of your avatar when rolling your HMD in degrees per second.

userHeight number

The height of the user in sensor space.

Default Value: 1.75

userEyeHeight number

The estimated height of the user's eyes in sensor space. Read-only.

Default Value: 1.65

SELF_ID Uuid

UUID representing "my avatar". Only use for local-only entities in situations where MyAvatar.sessionUUID is not available (e.g., if not connected to a domain). Note: Likely to be deprecated. Read-only.

walkSpeed number

The walk speed of your avatar for the current control scheme (see getControlScheme).

walkBackwardSpeed number

The walk backward speed of your avatar for the current control scheme (see getControlScheme).

sprintSpeed number

The sprint (run) speed of your avatar for the current control scheme (see getControlScheme).

analogPlusWalkSpeed number

The walk speed of your avatar for the "AnalogPlus" control scheme.

Warning: Setting this value also sets the value of analogPlusSprintSpeed to twice the value.

analogPlusSprintSpeed number

The sprint (run) speed of your avatar for the "AnalogPlus" control scheme.

userRecenterModel MyAvatar.SitStandModelType

Controls avatar leaning and recentering behavior.

Deprecated: This property is deprecated and will be removed.

isInSittingState boolean

true if the user wearing the HMD is determined to be sitting; false if the user wearing the HMD is determined to be standing. This can affect whether the avatar is allowed to stand, lean or recenter its footing, depending on user preferences. The property value automatically updates as the user sits or stands. Setting the property value overrides the current sitting / standing state, which is updated when the user next sits or stands.

isSitStandStateLocked boolean

true to lock the avatar sitting/standing state, i.e., use this to disable automatically changing state.

Deprecated: This property is deprecated and will be removed. See also: getUserRecenterModel and setUserRecenterModel.

allowTeleporting boolean

true if teleporting is enabled in the Interface settings, false if it isn't. Read-only.

Methods

Name Return Value Summary
addAnimationStateHandler number

Adds an animation state handler function that is invoked just before each animation graph update. More than one animation state handler function may be added by calling addAnimationStateHandler multiple times. It is not specified in what order multiple handlers are called.

The animation state handler function is called with an AnimStateDictionary "animStateDictionaryIn" parameter and is expected to return an AnimStateDictionary "animStateDictionaryOut" object. The animStateDictionaryOut object can be the same object as animStateDictionaryIn, or it can be a different object. The animStateDictionaryIn may be shared among multiple handlers and thus may contain additional properties specified when adding the different handlers.

A handler may change a value from animStateDictionaryIn or add different values in the animStateDictionaryOut returned. Any property values set in animStateDictionaryOut will override those of the internal animation machinery.

addThrust None

Adds a thrust to your avatar's current thrust to be applied for a short while.

Deprecated: This function is deprecated and will be removed. Use MyAvatar.motorVelocity and related properties instead.

animGraphLoaded None

Deprecated: This function is deprecated and will be removed.

attach 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.

beginReaction boolean

Starts playing a reaction on the avatar. The reaction will continue to play until stopped using MyAvatar.endReaction or superseded by another reaction.

Only reactions returned by MyAvatar.getBeginEndReactions are available.

beginSit None

Starts a sitting action for the avatar.

centerBody None

Moves and orients the avatar, such that it is directly underneath the HMD, with toes pointed forward in the direction of the HMD.

clearAvatarEntity None

Deprecated: This function is deprecated and will be removed.

clearIKJointLimitHistory None

Clears inverse kinematics joint limit history.

The internal inverse-kinematics system maintains a record of which joints are "locked". Sometimes it is useful to forget this history to prevent contorted joints, e.g., after finishing with an override animation.

clearJointData 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.

Note: This is slightly faster than the function variation that specifies the joint name.

clearJointData 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.

Note: This is slightly slower than the function variation that specifies the joint index.

clearJointsData None

Clears all joint translations and rotations that have been set by script. This restores all motion from the default animation system including inverse kinematics for all joints.

clearPinOnJoint boolean

Clears a lock on a joint's position and orientation, as set by pinJoint.

Note: Only works on the hips joint.

clearScaleRestriction None

Deprecated: This function is deprecated and will be removed.

decreaseSize None

Decreases the avatar's scale by five percent, down to a minimum scale of 0.25.

detachAll None

Detaches all instances of a particular model from either a specific joint or all joints.

Deprecated: This function is deprecated and will be removed. Use avatar entities instead.

detachOne None

Detaches the most recently attached instance of a particular model from either a specific joint or any joint.

Deprecated: This function is deprecated and will be removed. Use avatar entities instead.

disableDriveKey None

Disables the action associated with a drive key.

disableHandTouchForID None

Disables the hand touch effect on a specific entity.

The hand touch effect makes the avatar's fingers adapt to the shape of any object grabbed, creating the effect that it is really touching that object.

enableDriveKey None

Enables the action associated with a drive key. The action may have been disabled with disableDriveKey.

enableHandTouchForID None

Enables the hand touch effect on a specific entity.

The hand touch effect makes the avatar's fingers adapt to the shape of any object grabbed, creating the effect that it is really touching that object.

endReaction boolean

Stops playing a reaction that was started using MyAvatar.beginReaction.

endSit None

Ends a sitting action for the avatar.

getAbsoluteDefaultJointRotationInObjectFrame Quat

Gets the default joint rotations in avatar coordinates. The default pose of the avatar is defined by the position and orientation of all bones in the avatar's model file. Typically this is a T-pose.

getAbsoluteDefaultJointTranslationInObjectFrame Vec3

Gets the default joint translations in avatar coordinates. The default pose of the avatar is defined by the position and orientation of all bones in the avatar's model file. Typically this is a T-pose.

getAbsoluteJointRotationInObjectFrame Quat

Gets the rotation of a joint relative to the avatar.

getAbsoluteJointTranslationInObjectFrame Vec3

Gets the translation of a joint relative to the avatar.

getAcceleration Vec3

Gets the current acceleration of the avatar.

getAnimationRoles Array.<string>

Gets the current animation roles.

Each avatar has an avatar-animation.json file that defines which animations are used and how they are blended together with procedural data (such as look at vectors, hand sensors etc.). Each animation specified in the avatar-animation.json file is known as an animation role. Animation roles map to easily understandable actions that the avatar can perform, such as "idleStand", "idleTalk", or "walkFwd". getAnimationRoles() is used get the list of animation roles defined in the avatar-animation.json.

getAnimGraphOverrideUrl string

Gets the URL of the override animation graph.

See Custom Avatar Animations for information on animation graphs.

getAnimGraphUrl string

Gets the URL of animation graph (i.e., the avatar animation JSON) that's currently being used for avatar animations.

See Custom Avatar Animations for information on animation graphs.

getAttachmentData Array.<AttachmentData>

Gets information about the models currently attached to your avatar.

Deprecated: This function is deprecated and will be removed. Use avatar entities instead.

getAttachmentsVariant Array.<AttachmentData>

Gets information about the models currently attached to your avatar.

Deprecated: This function is deprecated and will be removed. Use avatar entities instead.

getAvatarEntitiesVariant Array.<MyAvatar.AvatarEntityData>

Gets the current avatar entity IDs and their properties.

getAvatarEntityData AvatarEntityMap

Gets details of all avatar entities.

Warning: Potentially an expensive call. Do not use if possible.

getAvatarScale 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.

getBeginEndReactions Array.<string>

Gets the list of reactions names that can be enabled using MyAvatar.beginReaction and MyAvatar.endReaction.

See also: MyAvatar.getTriggerReactions.

getCenterOfGravityModelEnabled boolean

Gets whether the avatar hips are being balanced over the feet or placed under the head.

getCharacterControllerEnabled boolean

Deprecated: This function is deprecated and will be removed. Use MyAvatar.getCollisionsEnabled instead.

getCollidingFlowJoints Array.<number>

Gets the indexes of currently colliding flow joints.

getCollisionCapsule MyAvatar.CollisionCapsule

Gets the avatar's collision capsule: a cylinder with hemispherical ends that approximates the extents or the avatar.

Warning: The values returned are in world coordinates but aren't necessarily up to date with the avatar's current position.

getCollisionsEnabled boolean

Gets whether the avatar will currently collide with entities.

Note: The avatar will always collide with entities if in a zone that disallows collisionless avatars.

getControllerLeftHandMatrix Mat4

Gets the rotation and translation of the left hand controller relative to the avatar.

getControllerRightHandMatrix Mat4

Gets the rotation and translation of the right hand controller relative to the avatar.

getControlScheme MyAvatar.LocomotionControlsMode

Gets the control scheme that is in use.

getDataRate number

Gets the amount of avatar mixer data being generated by the avatar.

getDefaultEyePosition Vec3

Gets the position in world coordinates of the point directly between your avatar's eyes assuming your avatar was in its default pose. This is a reference position; it does not change as your avatar's head moves relative to the avatar position.

getDefaultJointRotation Quat

Gets the default rotation of a joint (in the current avatar) relative to its parent.

For information on the joint hierarchy used, see Avatar Standards.

getDefaultJointTranslation Vec3

Gets the default translation of a joint (in the current avatar) relative to its parent, in model coordinates.

Warning: These coordinates are not necessarily in meters.

For information on the joint hierarchy used, see Avatar Standards.

getDomainMaxScale number

Gets the maximum scale allowed for this avatar in the current domain. This value can change as the user changes avatars or when changing domains.

getDomainMinScale number

Gets the minimum scale allowed for this avatar in the current domain. This value can change as the user changes avatars or when changing domains.

getDominantHand string

Gets the avatar's dominant hand.

getDriveGear1 number

Get the first 'shifting point' for acceleration step function.

getDriveGear2 number

Get the second 'shifting point' for acceleration step function.

getDriveGear3 number

Get the third 'shifting point' for acceleration step function.

getDriveGear4 number

Get the fourth 'shifting point' for acceleration step function.

getDriveGear5 number

Get the fifth 'shifting point' for acceleration step function.

getEnableMeshVisible boolean

Gets whether your avatar mesh is visible.

getEyeHeight number

Gets the current eye height of the avatar. This height is only an estimate and might be incorrect for avatars that are missing standard joints.

getEyePosition Vec3

Gets the current position of the point directly between the avatar's eyes.

getEyesLookAt Vec3

Gets the current target point of the eyes look direction in world coordinates.

getFlowData MyAvatar.FlowData

Gets the current flow configuration.

getFlyingDesktopPref boolean

Gets your preference for flying in desktop display mode. Note that your ability to fly also depends on whether the domain you're in allows you to fly.

getFlyingEnabled boolean

Gets your preference for flying in your current desktop or HMD display mode. Note that your ability to fly also depends on whether the domain you're in allows you to fly.

getFlyingHMDPref boolean

Gets your preference for flying in HMD display mode. Note that your ability to fly also depends on whether the domain you're in allows you to fly.

getFullAvatarModelName string

Gets the full avatar model name for the current avatar.

getFullAvatarURLFromPreferences string

Gets the complete URL for the current avatar.

getGravity number

Sets the amount of gravity applied to the avatar in the y-axis direction. (Negative values are downward.) The default value is -5 m/s2.

getHandRelativeMovement number

Get your preference for hand-relative movement.

getHandState HandState

Gets the pointing state of the hands to control where the laser emanates from. If the right index finger is pointing, the laser emanates from the tip of that finger, otherwise it emanates from the palm.

getHeadDeltaPitch number

If a face tracker is connected and being used, gets the estimated pitch of the user's head scaled. This is scale such that the avatar looks at the edge of the view frustum when the user looks at the edge of their screen.

getHeadFinalPitch number

Gets the pitch of the avatar's head relative to its body.

getHeadFinalRoll number

Gets the roll of the avatar's head relative to its body.

getHeadFinalYaw number

Gets the yaw of the avatar's head relative to its body.

getHeadLookAt Vec3

Gets the current target point of the head's look direction in world coordinates.

getHeadPosition Vec3

Gets the current position of the avatar's "Head" joint.

getHeight 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.

getHmdAvatarAlignmentType string

Gets the HMD alignment relative to your avatar.

getHMDLeanRecenterEnabled boolean

Gets whether the avatar's position updates to recenter the avatar under the head. In room-scale VR, recentering causes your avatar to follow your HMD as you walk around the room.

getIKErrorOnLastSolve number

Gets the maximum error distance from the most recent inverse kinematics (IK) solution.

getJointIndex 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, or Avatar.getJointNames if using the Avatar API.

getJointNames Array.<string>

Gets the names of all the joints in the current avatar.

getJointPosition Vec3

Gets the position of a joint in the current avatar.

getJointPosition Vec3

Gets the position of a joint in the current avatar.

getJointRotation Quat

Gets the rotation of a joint relative to its parent. For information on the joint hierarchy used, see Avatar Standards.

getJointRotation Quat

Gets the rotation of a joint relative to its parent. For information on the joint hierarchy used, see Avatar Standards.

getJointRotations Array.<Quat>

Gets the rotations of all joints in the current avatar. Each joint's rotation is relative to its parent joint.

getJointTranslation Vec3

Gets the translation of a joint relative to its parent, in model coordinates.

Warning: These coordinates are not necessarily in meters.

For information on the joint hierarchy used, see Avatar Standards.

getJointTranslation Vec3

Gets the translation of a joint relative to its parent, in model coordinates.

Warning: These coordinates are not necessarily in meters.

For information on the joint hierarchy used, see Avatar Standards.

getJointTranslations Array.<Vec3>

Gets the translations of all joints in the current avatar. Each joint's translation is relative to its parent joint, in model coordinates.

Warning: These coordinates are not necessarily in meters.

getLeftHandPose Pose

Gets the pose (position, rotation, velocity, and angular velocity) of the avatar's left hand as positioned by a hand controller (e.g., Oculus Touch or Vive).

Note: The Leap Motion isn't part of the hand controller input system. (Instead, it manipulates the avatar's joints for hand animation.) If you are using the Leap Motion, the return value's valid property will be false and any pose values returned will not be meaningful.

getLeftHandPosition Vec3

Gets the position of the avatar's left hand, relative to the avatar, as positioned by a hand controller (e.g., Oculus Touch or Vive).

Note: The Leap Motion isn't part of the hand controller input system. (Instead, it manipulates the avatar's joints for hand animation.)

getLeftHandTipPose Pose

Gets the pose (position, rotation, velocity, and angular velocity) of the avatar's left hand, relative to the avatar, as positioned by a hand controller (e.g., Oculus Touch or Vive), and translated 0.3m along the palm.

Note: Leap Motion isn't part of the hand controller input system. (Instead, it manipulates the avatar's joints for hand animation.) If you are using Leap Motion, the return value's valid property will be false and any pose values returned will not be meaningful.

getLeftHandTipPosition Vec3

Gets the position 0.3m in front of the left hand's position in the direction along the palm, in avatar coordinates, as positioned by a hand controller.

getLeftPalmPosition Vec3

Gets the position of the left palm in world coordinates.

getLeftPalmRotation Quat

Gets the rotation of the left palm in world coordinates.

getNeckPosition Vec3

Gets the position of the current avatar's neck in world coordinates.

getOrientationForAudio Quat

Gets the orientation of your listening position for spatialized audio. The orientation depends on the value of the audioListenerMode property.

getOrientationVar object

Gets the avatar orientation. Suitable for use in QML.

getOtherAvatarsCollisionsEnabled boolean

Gets whether the avatar will collide with other avatars.

getParentID Uuid

Gets the ID of the entity or avatar that the avatar is parented to.

getParentJointIndex number

Gets the joint of the entity or avatar that the avatar is parented to.

getPositionForAudio Vec3

Gets your listening position for spatialized audio. The position depends on the value of the audioListenerMode property.

getRawDriveKey number

Gets the value of a drive key, regardless of whether it is disabled.

getRightHandPose Pose

Gets the pose (position, rotation, velocity, and angular velocity) of the avatar's left hand as positioned by a hand controller (e.g., Oculus Touch or Vive).

Note: The Leap Motion isn't part of the hand controller input system. (Instead, it manipulates the avatar's joints for hand animation.) If you are using the Leap Motion, the return value's valid property will be false and any pose values returned will not be meaningful.

getRightHandPosition Vec3

Gets the position of the avatar's right hand, relative to the avatar, as positioned by a hand controller (e.g., Oculus Touch or Vive).

Note: The Leap Motion isn't part of the hand controller input system. (Instead, it manipulates the avatar's joints for hand animation.)

getRightHandTipPose Pose

Gets the pose (position, rotation, velocity, and angular velocity) of the avatar's right hand, relative to the avatar, as positioned by a hand controller (e.g., Oculus Touch or Vive), and translated 0.3m along the palm.

Note: Leap Motion isn't part of the hand controller input system. (Instead, it manipulates the avatar's joints for hand animation.) If you are using Leap Motion, the return value's valid property will be false and any pose values returned will not be meaningful.

getRightHandTipPosition Vec3

Gets the position 0.3m in front of the right hand's position in the direction along the palm, in avatar coordinates, as positioned by a hand controller.

getRightPalmPosition Vec3

Gets the position of the right palm in world coordinates.

getRightPalmRotation Quat

Get the rotation of the right palm in world coordinates.

getSensorToWorldMatrix Mat4

Gets the transform from the user's real world to the avatar's size, orientation, and position in the virtual world.

getSensorToWorldScale number

Gets the scale that transforms dimensions in the user's real world to the avatar's size in the virtual world.

getSimulationRate number

Deprecated: This function is deprecated and will be removed.

getSkeleton Array.<SkeletonJoint>

Gets information on all the joints in the avatar's skeleton.

getSkeletonOffset Vec3

Gets the offset applied to the current avatar. The offset adjusts the position that the avatar is rendered. For example, with an offset of { x: 0, y: 0.1, z: 0 }, your avatar will appear to be raised off the ground slightly.

getSnapTurn boolean

Gets whether you do snap turns in HMD mode.

getStrafeEnabled boolean

Gets whether strafing is enabled.

getTargetAvatar ScriptAvatar

Gets information on the avatar your avatar is currently looking at.

getTargetAvatarPosition Vec3

Gets the position of the avatar your avatar is currently looking at.

getTargetScale number

Gets the target scale of the avatar without any restrictions on permissible values imposed by the domain. In contrast, the scale property's value may be limited by the domain's settings.

getThrust Vec3

Gets the thrust currently being applied to your avatar.

Deprecated: This function is deprecated and will be removed. Use MyAvatar.motorVelocity and related properties instead.

getTriggerReactions Array.<string>

Gets the list of reactions names that can be triggered using MyAvatar.triggerReaction.

See also: MyAvatar.getBeginEndReactions.

getUpdateRate number

Gets the update rate of avatar mixer data being generated by the avatar.

getWorldFeetPosition Vec3

Gets the position of the current avatar's feet (or rather, bottom of its collision capsule) in world coordinates.

goToFeetLocation None

Moves the avatar to a new position and/or orientation in the domain, with safe landing, while taking into account avatar leg length.

goToLocation None

Moves the avatar to a new position and/or orientation in the domain.

goToLocation None

Moves the avatar to a new position and (optional) orientation in the domain, with safe landing.

goToLocationAndEnableCollisions None

Moves the avatar to a new position, with safe landing, and enables collisions.

grab Uuid

Creates a new grab that grabs an entity.

hoverWhenUnsupported boolean

Gets whether your avatar hovers when its feet are not on the ground.

increaseSize None

Increases the avatar's scale by five percent, up to a minimum scale of 1000.

isDown boolean

Tests whether a vector is pointing in the general direction of the avatar's "down" direction (i.e., dot product of vectors is < 0).

isDriveKeyDisabled boolean

Checks whether a drive key is disabled.

isFlying boolean

Checks whether your avatar is flying.

isInAir boolean

Checks whether your avatar is in the air.

isJointDataValid boolean

Checks that the data for a joint are valid.

isJointDataValid boolean

Checks if the data for a joint are valid.

isRecenteringHorizontally boolean

Gets whether the avatar is configured to keep its center of gravity under its head.

isSeated boolean

Gets whether the avatar is in a seated pose. The seated pose is set by calling MyAvatar.beginSit.

isUp boolean

Tests whether a vector is pointing in the general direction of the avatar's "up" direction (i.e., dot product of vectors is > 0).

jointToWorldDirection Vec3

Transforms a direction in a joint's coordinates, or avatar coordinates if no joint is specified, to a direction in world coordinates.

jointToWorldPoint Vec3

Transforms a position in a joint's coordinates, or avatar coordinates if no joint is specified, to a position in world coordinates.

jointToWorldRotation Quat

Transforms a rotation in a joint's coordinates, or avatar coordinates if no joint is specified, to a rotation in world coordinates.

overrideAnimation None

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.). overrideAnimation() is used to completely override all motion from the default animation system (including inverse kinematics for hand and head controllers) and play a set of specified animations. To end these animations and restore the default animations, use MyAvatar.restoreAnimation.

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. For more information about avatar joint orientation standards, see Avatar Standards.

overrideHandAnimation None

Overrides the default hand poses that are triggered with controller buttons. Use MyAvatar.restoreHandAnimation to restore the default poses.

overrideRoleAnimation None

Overrides a specific animation role.

Each avatar has an avatar-animation.json file that defines a set of animation roles. Animation roles map to easily understandable actions that the avatar can perform, such as "idleStand", "idleTalk", or "walkFwd". To get the full list of roles, use {@ link MyAvatar.getAnimationRoles}. For each role, the avatar-animation.json defines when the animation is used, the animation clip (glTF or FBX) used, and how animations are blended together with procedural data (such as look at vectors, hand sensors etc.). overrideRoleAnimation() is used to change the animation clip (glTF or FBX) associated with a specified animation role. To end the role animation and restore the default, use MyAvatar.restoreRoleAnimation.

Note: Hand roles only affect the hand. Other "main" roles, like "idleStand", "idleTalk", and "takeoffStand", are full body.

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. For more information about avatar joint orientation standards, see Avatar Standards.

pinJoint boolean

Sets and locks a joint's position and orientation.

Note: Only works on the hips joint.

releaseEyesLookAtControl None

Returns control of the avatar's eyes to the engine, and releases control from API calls.

releaseGrab None

Releases (deletes) a grab to stop grabbing an entity.

releaseHeadLookAtControl None

Returns control of the avatar's head to the engine, and releases control from API calls.

removeAnimationStateHandler None

Removes an animation state handler function.

requestDisableHandTouch None

Requests that the hand touch effect is enabled for your avatar. Any resulting change in the status of the hand touch effect will be signaled by MyAvatar.shouldDisableHandTouchChanged.

The hand touch effect makes the avatar's fingers adapt to the shape of any object grabbed, creating the effect that it is really touching that object.

requestEnableHandTouch None

Requests that the hand touch effect is disabled for your avatar. Any resulting change in the status of the hand touch effect will be signaled by MyAvatar.shouldDisableHandTouchChanged.

The hand touch effect makes the avatar's fingers adapt to the shape of any object grabbed, creating the effect that it is really touching that object.

resetLastSent None

Deprecated: This function is deprecated and will be removed.

resetSensorsAndBody None

Resets the sensor positioning of your HMD (if in use) and recenters your avatar body and head.

resetSize None

Resets the avatar's scale back to the default scale of 1.0.

restoreAnimation None

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. restoreAnimation() is used to restore all motion from the default animation system including inverse kinematics for hand and head controllers. If you aren't currently playing an override animation, this function has no effect.

restoreHandAnimation None

Restores the default hand animation state machine that is driven by the state machine in the avatar-animation JSON.

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. restoreHandAnimation() is used to restore the default hand poses. If you aren't currently playing an override hand animation, this function has no effect.

restoreRoleAnimation None

Restores a default role animation.

Each avatar has an avatar-animation.json file that defines a set of animation roles. Animation roles map to easily understandable actions that the avatar can perform, such as "idleStand", "idleTalk", or "walkFwd". To get the full list of roles, use MyAvatar.getAnimationRoles. For each role, the avatar-animation.json defines when the animation is used, the animation clip (glTF or FBX) used, and how animations are blended together with procedural data (such as look-at vectors, hand sensors etc.). You can change the animation clip (glTF or FBX) associated with a specified animation role using MyAvatar.overrideRoleAnimation. restoreRoleAnimation() is used to restore a specified animation role's default animation clip. If you have not specified an override animation for the specified role, this function has no effect.

restrictScaleFromDomainSettings None

Deprecated: This function is deprecated and will be removed.

rigReady None

Deprecated: This function is deprecated and will be removed.

rigReset None

Deprecated: This function is deprecated and will be removed.

safeLanding boolean

Deprecated: This function is deprecated and will be removed.

sanitizeAvatarEntityProperties None

Deprecated: This function is deprecated and will be removed.

sendAvatarDataPacket number

Deprecated: This function is deprecated and will be removed.

sendIdentityPacket number

Deprecated: This function is deprecated and will be removed.

setAbsoluteJointRotationInObjectFrame boolean

Sets the rotation of a joint relative to the avatar.

Warning: Not able to be used in the MyAvatar API.

setAbsoluteJointTranslationInObjectFrame boolean

Sets the translation of a joint relative to the avatar.

Warning: Not able to be used in the MyAvatar API.

setAnimGraphOverrideUrl None

Sets the animation graph to use in preference to the default animation graph.

See Custom Avatar Animations for information on animation graphs.

setAnimGraphUrl None

Sets the current animation graph (i.e., the avatar animation JSON) to use for avatar animations and makes it the default.

See Custom Avatar Animations for information on animation graphs.

setAttachmentData None

Sets all models currently attached to your avatar. For example, if you retrieve attachment data using MyAvatar.getAttachmentData or Avatar.getAttachmentData, make changes to it, and then want to update your avatar's attachments per the changed data. You can also remove all attachments by using setting attachmentData to null.

Deprecated: This function is deprecated and will be removed. Use avatar entities instead.

setAttachmentsVariant None

Sets all models currently attached to your avatar. For example, if you retrieve attachment data using MyAvatar.getAttachmentsVariant or Avatar.getAttachmentsVariant, make changes to it, and then want to update your avatar's attachments per the changed data.

Deprecated: This function is deprecated and will be removed. Use avatar entities instead.

setAvatarEntityData None

Sets all avatar entities from an object.

setAvatarScale 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.

setBlendshape None

Sets the value of a blend shape to animate your avatar's face. In order for other users to see the resulting animations on your avatar's face, set hasScriptedBlendshapes to true. When you are done using this API, set hasScriptedBlendshapes back to false when the animation is complete.

setCenterOfGravityModelEnabled None

Sets whether the avatar's hips are balanced over the feet or positioned under the head.

setCharacterControllerEnabled None

Deprecated: This function is deprecated and will be removed. Use MyAvatar.setCollisionsEnabled instead.

setCollisionsEnabled None

Sets whether the avatar should collide with entities.

Note: A false value won't disable collisions if the avatar is in a zone that disallows collisionless avatars. However, the false value will be set so that collisions are disabled as soon as the avatar moves to a position where collisionless avatars are allowed.

setControlScheme None

Sets the control scheme to use.

setDebugDrawAnimPoseName None

Sets the animation node to display when animation debug graphics are enabled with MyAvatar.setEnableDebugDrawAnimPose.

setDominantHand None

Sets the avatar's dominant hand.

setDriveGear1 None

Set the first 'shifting point' for acceleration step function.

setDriveGear2 None

Set the second 'shifting point' for acceleration step function.

setDriveGear3 None

Set the third 'shifting point' for acceleration step function.

setDriveGear4 None

Set the fourth 'shifting point' for acceleration step function.

setDriveGear5 None

Set the fifth 'shifting point' for acceleration step function.

setEnableDebugDrawAnimPose None

Displays animation debug graphics. By default, the animation poses used for rendering are displayed. However, MyAvatar.setDebugDrawAnimPoseName can be used to set a specific animation node to display.

setEnableDebugDrawBaseOfSupport None

Displays the base of support area debug graphics if in HMD mode. If your head goes outside this area your avatar's hips are moved to counterbalance your avatar, and if your head moves too far then your avatar's position is moved (i.e., a step happens).

setEnableDebugDrawDefaultPose None

Displays default pose debug graphics.

setEnableDebugDrawDetailedCollision None

Displays detailed collision debug graphics.

setEnableDebugDrawHandControllers None

Displays controller hand target debug graphics.

setEnableDebugDrawIKChains None

Displays inverse kinematics chains debug graphics.

setEnableDebugDrawIKConstraints None

Displays inverse kinematics constraints debug graphics.

setEnableDebugDrawIKTargets None

Displays inverse kinematics targets debug graphics.

setEnableDebugDrawPosition None

Displays position debug graphics.

setEnableDebugDrawSensorToWorldMatrix None

Displays sensor-to-world matrix debug graphics.

setEnableInverseKinematics None

Sets whether inverse kinematics (IK) is enabled for your avatar.

setEnableMeshVisible None

Sets whether your avatar mesh is visible to you.

setEyesLookAt None

Forces the avatar's eyes to look at a specified location. Once this method is called, API calls full control of the eyes for a limited time. If this method is not called for 2 seconds, the engine regains control of the eyes.

setFlyingDesktopPref None

Sets your preference for flying in desktop display mode. Note that your ability to fly also depends on whether the domain you're in allows you to fly.

setFlyingEnabled None

Sets your preference for flying in your current desktop or HMD display mode. Note that your ability to fly also depends on whether the domain you're in allows you to fly.

setFlyingHMDPref None

Sets your preference for flying in HMD display mode. Note that your ability to fly also depends on whether the domain you're in allows you to fly.

setForceFaceTrackerConnected None

Enables blend shapes set using Avatar.setBlendshape or MyAvatar.setBlendshape to be transmitted to other users so that they can see the animation of your avatar's face.

Deprecated: This method is deprecated and will be removed. Use the Avatar.hasScriptedBlendshapes or MyAvatar.hasScriptedBlendshapes property instead.

setGravity None

Sets the amount of gravity applied to the avatar in the y-axis direction. (Negative values are downward.)

setHandRelativeMovement None

Set your preference for hand-relative movement.

setHandState None

Sets the pointing state of the hands to control where the laser emanates from. If the right index finger is pointing, the laser emanates from the tip of that finger, otherwise it emanates from the palm.

setHeadLookAt None

Turns the avatar's head until it faces the target point within a +90/-90 degree range. Once this method is called, API calls have full control of the head for a limited time. If this method is not called for 2 seconds, the engine regains control of the head.

setHmdAvatarAlignmentType None

Sets the HMD alignment relative to your avatar.

setHMDLeanRecenterEnabled None

Sets whether the avatar's position updates to recenter the avatar under the head. In room-scale VR, recentering causes your avatar to follow your HMD as you walk around the room. Disabling recentering is useful if you want to pin the avatar to a fixed position.

setHoverWhenUnsupported None

Sets whether your avatar hovers when its feet are not on the ground.

setJointData None

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.

setJointData None

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.

setJointRotation None

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.

setJointRotation None

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.

setJointRotations None

Sets the rotations of all joints in the current avatar. Each joint's rotation is relative to its parent joint.

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.

setJointTranslation None

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.

setJointTranslation None

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.

setJointTranslations None

Sets the translations of all joints in the current avatar. Each joint's translation is relative to its parent joint, 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.

setModelScale None

Deprecated: This function is deprecated and will be removed.

setModelURLFinished None

Deprecated: This function is deprecated and will be removed.

setOrientationVar None

Gets the avatar orientation. Suitable for use in QML.

setOtherAvatarsCollisionsEnabled None

Sets whether the avatar should collide with other avatars.

setParentID None

Sets the ID of the entity or avatar that the avatar is parented to.

setParentJointIndex None

Sets the joint of the entity or avatar that the avatar is parented to.

setPointAt boolean

Sets the point-at target for the "point" reaction that may be started with MyAvatar.beginReaction. The point-at target is set only if it is in front of the avatar.

Note: The "point" reaction should be started before calling this method.

setRawJointData None

Sets joint translations and rotations from raw joint data.

Deprecated: This function is deprecated and will be removed.

setSessionUUID None

Deprecated: This function is deprecated and will be removed.

setSkeletonModelURL None

Sets the avatar's skeleton model.

setSkeletonOffset None

Sets the offset applied to the current avatar. The offset adjusts the position that the avatar is rendered. For example, with an offset of { x: 0, y: 0.1, z: 0 }, your avatar will appear to be raised off the ground slightly.

setSnapTurn None

Sets whether you do snap turns or smooth turns in HMD mode.

setStrafeEnabled None

Sets whether strafing is enabled.

setThrust None

Sets the thrust to be applied to your avatar for a short while.

Deprecated: This function is deprecated and will be removed. Use MyAvatar.motorVelocity and related properties instead.

setToggleHips None

Deprecated: This function is deprecated and will be removed.

targetScaleChanged

Triggered when the avatar's target scale is changed. The target scale is the desired scale of the avatar without any restrictions on permissible scale values imposed by the domain.

triggerHorizontalRecenter None

Recenter the avatar in the horizontal direction, if MyAvatar.hmdLeanRecenterEnabled is false.

triggerReaction boolean

Plays a reaction on the avatar. Once the reaction is complete it will stop playing.

Only reaction names returned by MyAvatar.getTriggerReactions are available.

triggerRotationRecenter None

Recenter the avatar's rotation, if MyAvatar.hmdLeanRecenterEnabled is false.

triggerVerticalRecenter None

Recenter the avatar in the vertical direction, if MyAvatar.hmdLeanRecenterEnabled is false.

updateAvatarEntity None

Deprecated: This function is deprecated and will be removed.

updateMotionBehaviorFromMenu None

Updates avatar motion behavior from the Developer > Avatar > Enable Default Motor Control and Enable Scripted Motor Control menu items.

useFlow None

Enables and disables flow simulation of physics on the avatar's hair, clothes, and body parts. See Add Flow to Your Avatar for more information.

useFullAvatarURL None

Changes the user's avatar and associated descriptive name.

worldToJointDirection Vec3

Transforms a direction in world coordinates to a direction in a joint's coordinates, or avatar coordinates if no joint is specified.

worldToJointPoint Vec3

Transforms a position in world coordinates to a position in a joint's coordinates, or avatar coordinates if no joint is specified.

worldToJointRotation Quat

Transforms a rotation in world coordinates to a rotation in a joint's coordinates, or avatar coordinates if no joint is specified.

Signals

Name Summary
analogPlusSprintSpeedChanged

Triggered when the sprint (run) speed set for the "AnalogPlus" control scheme changes.

analogPlusWalkSpeedChanged

Triggered when the walk speed set for the "AnalogPlus" control scheme changes.

animGraphUrlChanged

Triggered when the avatar's animation graph being used changes.

attachmentsChanged

Triggered when the a model is attached to or detached from one of the avatar's joints using one of attach, detachOne, detachAll, or setAttachmentData.

Deprecated: This signal is deprecated and will be removed. Use avatar entities instead.

audioListenerModeChanged

Triggered when the audioListenerMode property value changes.

collisionsEnabledChanged

Triggered when collisions with the environment are enabled or disabled.

collisionWithEntity

Triggered when the avatar collides with an entity.

disableHandTouchForIDChanged

Triggered when the hand touch is enabled or disabled on a specific entity.

The hand touch effect makes the avatar's fingers adapt to the shape of any object grabbed, creating the effect that it is really touching that object.

displayNameChanged

Triggered when the avatar's displayName property value changes.

dominantHandChanged

Triggered when the avatar's dominant hand changes.

energyChanged

Deprecated: This signal is deprecated and will be removed.

hmdAvatarAlignmentTypeChanged

Triggered when the HMD alignment for your avatar changes.

lookAtSnappingChanged

Triggered when the avatar's lookAtSnappingEnabled property value changes.

newCollisionSoundURL

Triggered when the collisionSoundURL property value changes.

onLoadComplete

Triggered when the avatar's model finishes loading.

onLoadFailed

Triggered when the avatar's model has failed to load.

otherAvatarsCollisionsEnabledChanged

Triggered when collisions with other avatars are enabled or disabled.

positionGoneTo

Triggered when the avatar has been moved to a new position by one of the MyAvatar "goTo" functions.

scaleChanged

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.

sensorToWorldScaleChanged

Triggered when the avatar's sensorToWorldScale property value changes.

sessionDisplayNameChanged

Triggered when the avatar's sessionDisplayName property value changes.

sessionUUIDChanged

Triggered when the avatar's sessionUUID property value changes.

shouldDisableHandTouchChanged

Triggered when the hand touch effect is enabled or disabled for the avatar.

The hand touch effect makes the avatar's fingers adapt to the shape of any object grabbed, creating the effect that it is really touching that object.

skeletonChanged

Triggered when the avatar's model (i.e., skeletonModelURL property value) is changed.

Synonym of skeletonModelURLChanged.

skeletonModelURLChanged

Triggered when the avatar's model (i.e., skeletonModelURL property value) changes.

sprintSpeedChanged

Triggered when the sprint (run) speed set for the current control scheme (see getControlScheme) changes.

transformChanged

Deprecated: This signal is deprecated and will be removed.

walkBackwardSpeedChanged

Triggered when the walk backward speed set for the current control scheme (see getControlScheme) changes.

wentActive

Triggered when your avatar changes from being away to being active.

wentAway

Triggered when your avatar changes from being active to being away.

Type Definitions

AnimIKSolutionSource
Type: number

Specifies the initial conditions of the IK solver.

ValueNameDescription
0RelaxToUnderPosesThis is a blend: it is 15/16 PreviousSolution and 1/16 UnderPoses. This provides some of the benefits of using UnderPoses so that the underlying animation is still visible, while at the same time converging faster then using the UnderPoses as the only initial solution.
1RelaxToLimitCenterPosesThis is a blend: it is 15/16 PreviousSolution and 1/16 LimitCenterPoses. This should converge quickly because it is close to the previous solution, but still provides the benefits of avoiding limb locking.
2PreviousSolution

The IK system will begin to solve from the same position and orientations for each joint that was the result from the previous frame.

Pros: As the end effectors typically do not move much from frame to frame, this is likely to converge quickly to a valid solution.

Cons: If the previous solution resulted in an awkward or uncomfortable posture, the next frame will also be awkward and uncomfortable. It can also result in locked elbows and knees.

3UnderPosesThe IK occurs at one of the top-most layers. It has access to the full posture that was computed via canned animations and blends. We call this animated set of poses the "under pose". The under poses are what would be visible if IK was completely disabled. Using the under poses as the initial conditions of the CCD solve will cause some of the animated motion to be blended into the result of the IK. This can result in very natural results, especially if there are only a few IK targets enabled. On the other hand, because the under poses might be quite far from the desired end effector, it can converge slowly in some cases, causing it to never reach the IK target in the allotted number of iterations. Also, in situations where all of the IK targets are being controlled by external sensors, sometimes starting from the under poses can cause awkward motions from the underlying animations to leak into the IK result.
4LimitCenterPosesThis pose is taken to be the center of all the joint constraints. This can prevent the IK solution from getting locked or stuck at a particular constraint. For example, if the arm is pointing straight outward from the body, as the end effector moves towards the body, at some point the elbow should bend to accommodate. However, because the CCD solver is stuck at a local maximum, it will not rotate the elbow, unless the initial conditions already have the elbow bent, which is the case for LimitCenterPoses. When all the IK targets are enabled, this result will provide a consistent starting point for each IK solve, hopefully resulting in a consistent, natural result.
AnimOverlayBoneSet
Type: number

Specifies sets of joints.

ValueNameDescription
0FullBodyBoneSetAll joints.
1UpperBodyBoneSetOnly the "Spine" joint and its children.
2LowerBodyBoneSetOnly the leg joints and their children.
3LeftArmBoneSetJoints that are the children of the "LeftShoulder" joint.
4RightArmBoneSetJoints that are the children of the "RightShoulder" joint.
5AboveTheHeadBoneSetJoints that are the children of the "Head" joint.
6BelowTheHeadBoneSetJoints that are NOT the children of the "head" joint.
7HeadOnlyBoneSetThe "Head" joint.
8SpineOnlyBoneSetThe "Spine" joint.
9EmptyBoneSetNo joints.
10LeftHandBoneSetjoints that are the children of the "LeftHand" joint.
11RightHandBoneSetJoints that are the children of the "RightHand" joint.
12HipsOnlyBoneSetThe "Hips" joint.
13BothFeetBoneSetThe "LeftFoot" and "RightFoot" joints.
AnimStateDictionary
Type: object

An AnimStateDictionary object may have the following properties. It may also have other properties, set by scripts.

Warning: These properties are subject to change.

NameTypeDescription
userAnimNonebooleantrue when no user overrideAnimation is playing.
userAnimAbooleantrue when a user overrideAnimation is playing.
userAnimBbooleantrue when a user overrideAnimation is playing.
sinenumberOscillating sine wave.
moveForwardSpeednumberControls the blend between the various forward walking & running animations.
moveBackwardSpeednumberControls the blend between the various backward walking & running animations.
moveLateralSpeednumberControls the blend between the various sidestep walking & running animations.
isMovingForwardbooleantrue if the avatar is moving forward.
isMovingBackwardbooleantrue if the avatar is moving backward.
isMovingRightbooleantrue if the avatar is moving to the right.
isMovingLeftbooleantrue if the avatar is moving to the left.
isMovingRightHmdbooleantrue if the avatar is moving to the right while the user is in HMD mode.
isMovingLeftHmdbooleantrue if the avatar is moving to the left while the user is in HMD mode.
isNotMovingbooleantrue if the avatar is stationary.
isTurningRightbooleantrue if the avatar is turning clockwise.
isTurningLeftbooleantrue if the avatar is turning counter-clockwise.
isNotTurningbooleantrue if the avatar is not turning.
isFlyingbooleantrue if the avatar is flying.
isNotFlyingbooleantrue if the avatar is not flying.
isTakeoffStandbooleantrue if the avatar is about to execute a standing jump.
isTakeoffRunbooleantrue if the avatar is about to execute a running jump.
isNotTakeoffbooleantrue if the avatar is not jumping.
isInAirStandbooleantrue if the avatar is in the air after a standing jump.
isInAirRunbooleantrue if the avatar is in the air after a running jump.
isNotInAirbooleantrue if the avatar on the ground.
inAirAlphanumberUsed to interpolate between the up, apex, and down in-air animations.
ikOverlayAlphanumberThe blend between upper body and spline IK versus the underlying animation
headPositionVec3The desired position of the Head joint in rig coordinates.
headRotationQuatThe desired orientation of the Head joint in rig coordinates.
headTypeIKTargetTypeThe type of IK used for the head.
headWeightnumberHow strongly the head chain blends with the other IK chains.
leftHandPositionVec3The desired position of the LeftHand joint in rig coordinates.
leftHandRotationQuatThe desired orientation of the LeftHand joint in rig coordinates.
leftHandTypeIKTargetTypeThe type of IK used for the left arm.
leftHandPoleVectorEnabledbooleanWhen true, the elbow angle is controlled by the rightHandPoleVector property value. Otherwise the elbow direction comes from the underlying animation.
leftHandPoleReferenceVectorVec3The direction of the elbow in the local coordinate system of the elbow.
leftHandPoleVectorVec3The direction the elbow should point in rig coordinates.
rightHandPositionVec3The desired position of the RightHand joint in rig coordinates.
rightHandRotationQuatThe desired orientation of the RightHand joint in rig coordinates.
rightHandTypeIKTargetTypeThe type of IK used for the right arm.
rightHandPoleVectorEnabledbooleanWhen true, the elbow angle is controlled by the rightHandPoleVector property value. Otherwise the elbow direction comes from the underlying animation.
rightHandPoleReferenceVectorVec3The direction of the elbow in the local coordinate system of the elbow.
rightHandPoleVectorVec3The direction the elbow should point in rig coordinates.
leftFootIKEnabledbooleantrue if IK is enabled for the left foot.
rightFootIKEnabledbooleantrue if IK is enabled for the right foot.
leftFootIKPositionVarstringThe name of the source for the desired position of the LeftFoot joint. If not set, the foot rotation of the underlying animation will be used.
leftFootIKRotationVarstringThe name of the source for the desired rotation of the LeftFoot joint. If not set, the foot rotation of the underlying animation will be used.
leftFootPoleVectorEnabledbooleanWhen true, the knee angle is controlled by the leftFootPoleVector property value. Otherwise the knee direction comes from the underlying animation.
leftFootPoleVectorVec3The direction the knee should face in rig coordinates.
rightFootIKPositionVarstringThe name of the source for the desired position of the RightFoot joint. If not set, the foot rotation of the underlying animation will be used.
rightFootIKRotationVarstringThe name of the source for the desired rotation of the RightFoot joint. If not set, the foot rotation of the underlying animation will be used.
rightFootPoleVectorEnabledbooleanWhen true, the knee angle is controlled by the rightFootPoleVector property value. Otherwise the knee direction comes from the underlying animation.
rightFootPoleVectorVec3The direction the knee should face in rig coordinates.
isTalkingbooleantrue if the avatar is talking.
notIsTalkingbooleantrue if the avatar is not talking.
solutionSourceAnimIKSolutionSource Determines the initial conditions of the IK solver.
defaultPoseOverlayAlphanumberControls the blend between the main animation state machine and the default pose. Mostly used during full body tracking so that walking & jumping animations do not affect the IK of the figure.
defaultPoseOverlayBoneSetAnimOverlayBoneSet Specifies which bones will be replace by the source overlay.
hipsTypeIKTargetTypeThe type of IK used for the hips.
hipsPositionVec3The desired position of Hips joint in rig coordinates.
hipsRotationQuatthe desired orientation of the Hips joint in rig coordinates.
spine2TypeIKTargetTypeThe type of IK used for the Spine2 joint.
spine2PositionVec3The desired position of the Spine2 joint in rig coordinates.
spine2RotationQuatThe desired orientation of the Spine2 joint in rig coordinates.
leftFootIKAlphanumberBlends between full IK for the leg and the underlying animation.
rightFootIKAlphanumberBlends between full IK for the leg and the underlying animation.
hipsWeightnumberHow strongly the hips target blends with the IK solution for other IK chains.
leftHandWeightnumberHow strongly the left hand blends with IK solution of other IK chains.
rightHandWeightnumberHow strongly the right hand blends with IK solution of other IK chains.
spine2WeightnumberHow strongly the spine2 chain blends with the rest of the IK solution.
leftHandOverlayAlphanumberUsed to blend in the animated hand gesture poses, such as point and thumbs up.
leftHandGraspAlphanumberUsed to blend between an open hand and a closed hand. Usually changed as you squeeze the trigger of the hand controller.
rightHandOverlayAlphanumberUsed to blend in the animated hand gesture poses, such as point and thumbs up.
rightHandGraspAlphanumberUsed to blend between an open hand and a closed hand. Usually changed as you squeeze the trigger of the hand controller.
isLeftIndexPointbooleantrue if the left hand should be pointing.
isLeftThumbRaisebooleantrue if the left hand should be thumbs-up.
isLeftIndexPointAndThumbRaisebooleantrue if the left hand should be pointing and thumbs-up.
isLeftHandGraspbooleantrue if the left hand should be at rest, grasping the controller.
isRightIndexPointbooleantrue if the right hand should be pointing.
isRightThumbRaisebooleantrue if the right hand should be thumbs-up.
isRightIndexPointAndThumbRaisebooleantrue if the right hand should be pointing and thumbs-up.
isRightHandGraspbooleantrue if the right hand should be at rest, grasping the controller.

Note: Rig coordinates are +z forward and +y up.

AvatarEntityData
Type: object

Information about an avatar entity.

PropertyTypeDescription
idUuidEntity ID.
propertiesEntities.EntityPropertiesEntity properties.
CollisionCapsule
Type: object

A collision capsule is a cylinder with hemispherical ends. It is often used to approximate the extents of an avatar.

Properties

Name Type Summary
start Vec3

The bottom end of the cylinder, excluding the bottom hemisphere.

end Vec3

The top end of the cylinder, excluding the top hemisphere.

radius number

The radius of the cylinder and the hemispheres.

FlowCollisionsData
Type: object

A set of collision options currently used in flow simulation.

Properties

Name Type Summary
radius number

Collision sphere radius.

offset number

Offset of the collision sphere from the joint.

jointIndex number

The index of the joint the options are applied to.

FlowCollisionsOptions
Type: object

Collision options to use in the flow simulation of a joint.

Properties

Name Type Attributes Summary
type string <optional>

Currently, only "sphere" is supported.

Default Value: "sphere"

radius number <optional>

Collision sphere radius.

Default Value: 0.05

offset number <optional>

Offset of the collision sphere from the joint.

Default Value: Vec3.ZERO

FlowData
Type: object

Flow options currently used in flow simulation.

Properties

Name Type Summary
initialized boolean

true if flow has been initialized for the current avatar, false if it hasn't.

active boolean

true if flow is enabled, false if it isn't.

colliding boolean

true if collisions are enabled, false if they aren't.

physicsData Object.<GroupName, MyAvatar.FlowPhysicsData>

The physics configuration for each group of joints that has been configured.

collisions Object.<JointName, MyAvatar.FlowCollisionsData>

The collisions configuration for each joint that has collisions configured.

threads Object.<ThreadName, Array.<number>>

The threads that have been configured, with the first joint's name as the ThreadName and value as an array of the indexes of all the joints in the thread.

FlowPhysicsData
Type: object

A set of physics options currently used in flow simulation.

Properties

Name Type Summary
active boolean

true to enable flow on the joint, otherwise false.

radius number

The thickness of segments and knots. (Needed for collisions.)

gravity number

Y-value of the gravity vector.

inertia number

Rotational inertia multiplier.

damping number

The amount of damping on joint oscillation.

stiffness number

The stiffness of each thread.

delta number

Delta time for every integration step.

jointIndices Array.<number>

The indexes of the joints the options are applied to.

FlowPhysicsOptions
Type: object

Physics options to use in the flow simulation of a joint.

Properties

Name Type Attributes Summary
active boolean <optional>

true to enable flow on the joint, otherwise false.

Default Value: true

radius number <optional>

The thickness of segments and knots (needed for collisions).

Default Value: 0.01

gravity number <optional>

Y-value of the gravity vector.

Default Value: -0.0096

inertia number <optional>

Rotational inertia multiplier.

Default Value: 0.8

damping number <optional>

The amount of damping on joint oscillation.

Default Value: 0.85

stiffness number <optional>

The stiffness of each thread.

Default Value: 0.0

delta number <optional>

Delta time for every integration step.

Default Value: 0.55

GoToProperties
Type: object

A teleport target.

Properties

Name Type Attributes Summary
position Vec3

The avatar's new position.

orientation Quat <optional>

The avatar's new orientation.

IKTargetType
Type: number

An IK target type.

ValueNameDescription
0RotationAndPositionAttempt to reach the rotation and position end effector.
1RotationOnlyAttempt to reach the end effector rotation only.
2HmdHead

A special mode of IK that would attempt to prevent unnecessary bending of the spine.

Deprecated: This target type is deprecated and will be removed.

3HipsRelativeRotationAndPositionAttempt to reach a rotation and position end effector that is not in absolute rig coordinates but is offset by the avatar hips translation.
4SplineUse a cubic Hermite spline to model the human spine. This prevents kinks in the spine and allows for a small amount of stretch and squash.
5UnknownIK is disabled.
LocomotionControlsMode
Type: number

Locomotion control types.

ValueNameDescription
0DefaultYour walking speed is constant; it doesn't change depending on how far forward you push your controller's joystick. Fully pushing your joystick forward makes your avatar run.
1AnalogYour walking speed changes in steps based on how far forward you push your controller's joystick. Fully pushing your joystick forward makes your avatar run.
2AnalogPlusYour walking speed changes proportionally to how far forward you push your controller's joystick. Fully pushing your joystick forward makes your avatar run.
SitStandModelType
Type: number

Specifies different avatar leaning and recentering behaviors.

Deprecated: This type is deprecated and will be removed.

ValueNameDescription
0ForceSitAssumes the user is seated in the real world. Disables avatar leaning regardless of what the avatar is doing in the virtual world (i.e., avatar always recenters).
1ForceStandAssumes the user is standing in the real world. Enables avatar leaning regardless of what the avatar is doing in the virtual world (i.e., avatar leans, then if leans too far it recenters).
2AutoInterface detects when the user is standing or seated in the real world. Avatar leaning is disabled when the user is sitting (i.e., avatar always recenters), and avatar leaning is enabled when the user is standing (i.e., avatar leans, then if leans too far it recenters).
3DisableHMDLean

Both avatar leaning and recentering are disabled regardless of what the user is doing in the real world and no matter what their avatar is doing in the virtual world. Enables the avatar to sit on the floor when the user sits on the floor.

Note: Experimental.

Method Details

(static) addAnimationStateHandler( handler, propertiesList ) → {number}
Returns: The ID of the animation state handler function if successfully added, undefined if not.

Adds an animation state handler function that is invoked just before each animation graph update. More than one animation state handler function may be added by calling addAnimationStateHandler multiple times. It is not specified in what order multiple handlers are called.

The animation state handler function is called with an AnimStateDictionary "animStateDictionaryIn" parameter and is expected to return an AnimStateDictionary "animStateDictionaryOut" object. The animStateDictionaryOut object can be the same object as animStateDictionaryIn, or it can be a different object. The animStateDictionaryIn may be shared among multiple handlers and thus may contain additional properties specified when adding the different handlers.

A handler may change a value from animStateDictionaryIn or add different values in the animStateDictionaryOut returned. Any property values set in animStateDictionaryOut will override those of the internal animation machinery.

Parameters

Name Type Description
handler function

The animation state handler function to add.

propertiesList Array.<string> | null

The list of AnimStateDictionary properties that should be included in the parameter that the handler function is called with. If null then all properties are included in the call parameter.

Example

Log all the animation state dictionary parameters for a short while.

function animStateHandler(dictionary) {
    print("Anim state dictionary: " + JSON.stringify(dictionary));
}

var handler = MyAvatar.addAnimationStateHandler(animStateHandler, null);

Script.setTimeout(function () {
    MyAvatar.removeAnimationStateHandler(handler);
}, 100);
(static) addThrust( thrust )

Adds a thrust to your avatar's current thrust to be applied for a short while.

Deprecated: This function is deprecated and will be removed. Use MyAvatar.motorVelocity and related properties instead.

Parameters

Name Type Description
thrust Vec3

The thrust direction and magnitude.

(static) animGraphLoaded( )

Deprecated: This function is deprecated and will be removed.

(static) attach( modelURL, jointNameopt, translationopt, rotationopt, scaleopt, isSoftopt, allowDuplicatesopt, useSavedopt )

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.

Parameters

Name Type Attributes Default Value Description
modelURL string

The URL of the glTF, FBX, or OBJ model to attach. glTF models may be in JSON or binary format (".gltf" or ".glb" URLs respectively).

jointName string <optional>
""

The name of the avatar joint (see MyAvatar.getJointNames or Avatar.getJointNames) to attach the model to.

translation Vec3 <optional>
Vec3.ZERO

The offset to apply to the model relative to the joint position.

rotation Quat <optional>
Quat.IDENTITY

The rotation to apply to the model relative to the joint orientation.

scale number <optional>
1.0

The scale to apply to the model.

isSoft boolean <optional>
false

If the model has a skeleton, set this to true so that the bones of the attached model's skeleton are rotated to fit the avatar's current pose. isSoft is used, for example, to have clothing that moves with the avatar.

If true, the translation, rotation, and scale parameters are ignored.

allowDuplicates boolean <optional>
false

If true then more than one copy of any particular model may be attached to the same joint; if false then the same model cannot be attached to the same joint.

useSaved boolean <optional>
true

Not used.

Example

Attach a cowboy hat to your avatar's head.

var attachment = {
    modelURL: "https://apidocs.vircadia.dev/models/cowboy-hat.fbx",
    jointName: "Head",
    translation: {"x": 0, "y": 0.25, "z": 0},
    rotation: {"x": 0, "y": 0, "z": 0, "w": 1},
    scale: 0.01,
    isSoft: false
};

 MyAvatar.attach(attachment.modelURL,
                 attachment.jointName,
                 attachment.translation,
                 attachment.rotation,
                 attachment.scale,
                 attachment.isSoft);

// Note: If using from the Avatar API, replace "MyAvatar" with "Avatar".
(static) beginReaction( reactionName ) → {boolean}
Returns: true if the reaction was started, false if the reaction is not supported.

Starts playing a reaction on the avatar. The reaction will continue to play until stopped using MyAvatar.endReaction or superseded by another reaction.

Only reactions returned by MyAvatar.getBeginEndReactions are available.

Parameters

Name Type Description
reactionName string

The reaction to start playing.

(static) beginSit( position, rotation )

Starts a sitting action for the avatar.

Parameters

Name Type Description
position Vec3

The position where the avatar should sit.

rotation Quat

The initial orientation of the seated avatar.

(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.

(static) clearAvatarEntity( entityID, requiresRemovalFromTreeopt )

Deprecated: This function is deprecated and will be removed.

Parameters

Name Type Attributes Default Value Description
entityID Uuid

The entity ID.

requiresRemovalFromTree boolean <optional>
true

unused

(static) clearIKJointLimitHistory( )

Clears inverse kinematics joint limit history.

The internal inverse-kinematics system maintains a record of which joints are "locked". Sometimes it is useful to forget this history to prevent contorted joints, e.g., after finishing with an override animation.

(static) clearJointData( index )

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 faster than the function variation that specifies the joint name.

Parameters

Name Type Description
index number

The index of the joint.

(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

Name Type Description
name string

The name of the joint.

Example

Offset and restore the position of your avatar's head.

// Stretch your avatar's neck.
MyAvatar.setJointTranslation("Neck", Vec3.multiply(2, MyAvatar.getJointTranslation("Neck")));

// Restore your avatar's neck after 5s.
Script.setTimeout(function () {
    MyAvatar.clearJointData("Neck");
}, 5000);

// Note: If using from the Avatar API, replace all occurrences of "MyAvatar" with "Avatar".
(static) clearJointsData( )

Clears all joint translations and rotations that have been set by script. This restores all motion from the default animation system including inverse kinematics for all joints.

Example

Set your avatar to it's default T-pose for a while.

// Set all joint translations and rotations to defaults.
var i, length, rotation, translation;
for (i = 0, length = MyAvatar.getJointNames().length; i < length; i++) {
    rotation = MyAvatar.getDefaultJointRotation(i);
    translation = MyAvatar.getDefaultJointTranslation(i);
    MyAvatar.setJointData(i, rotation, translation);
}

// Restore your avatar's motion after 5s.
Script.setTimeout(function () {
    MyAvatar.clearJointsData();
}, 5000);

// Note: If using from the Avatar API, replace all occurrences of "MyAvatar" with "Avatar".
(static) clearPinOnJoint( index ) → {boolean}
Returns: true if the joint was unpinned, false if it wasn't.

Clears a lock on a joint's position and orientation, as set by pinJoint.

Note: Only works on the hips joint.

Parameters

Name Type Description
index number

The index of the joint.

(static) clearScaleRestriction( )

Deprecated: This function is deprecated and will be removed.

(static) decreaseSize( )

Decreases the avatar's scale by five percent, down to a minimum scale of 0.25.

Example

Reset your avatar's size to default then shrink it 5 times.

MyAvatar.resetSize();

for (var i = 0; i < 5; i++){
    print("Shrinking by 5 percent");
    MyAvatar.decreaseSize();
}
(static) detachAll( modelURL, jointNameopt )

Detaches all instances of a particular model from either a specific joint or all joints.

Deprecated: This function is deprecated and will be removed. Use avatar entities instead.

Parameters

Name Type Attributes Default Value Description
modelURL string

The URL of the model to detach.

jointName string <optional>
""

The name of the joint to detach the model from. If "", then the model is detached from all joints.

(static) detachOne( modelURL, jointNameopt )

Detaches the most recently attached instance of a particular model from either a specific joint or any joint.

Deprecated: This function is deprecated and will be removed. Use avatar entities instead.

Parameters

Name Type Attributes Default Value Description
modelURL string

The URL of the model to detach.

jointName string <optional>
""

The name of the joint to detach the model from. If "", then the most recently attached model is removed from which ever joint it was attached to.

(static) disableDriveKey( key )

Disables the action associated with a drive key.

Parameters

Name Type Description
key DriveKey

The drive key to disable.

Example

Disable rotating your avatar using the keyboard for a couple of seconds.

print("Disable");
MyAvatar.disableDriveKey(DriveKeys.YAW);
Script.setTimeout(function () {
    print("Enable");
    MyAvatar.enableDriveKey(YAW);
}, 5000);
(static) disableHandTouchForID( entityID )

Disables the hand touch effect on a specific entity.

The hand touch effect makes the avatar's fingers adapt to the shape of any object grabbed, creating the effect that it is really touching that object.

Parameters

Name Type Description
entityID Uuid

The entity that the hand touch effect will be disabled for.

(static) enableDriveKey( key )

Enables the action associated with a drive key. The action may have been disabled with disableDriveKey.

Parameters

Name Type Description
key DriveKey

The drive key to enable.

(static) enableHandTouchForID( entityID )

Enables the hand touch effect on a specific entity.

The hand touch effect makes the avatar's fingers adapt to the shape of any object grabbed, creating the effect that it is really touching that object.

Parameters

Name Type Description
entityID Uuid

The entity that the hand touch effect will be enabled for.

(static) endReaction( reactionName ) → {boolean}
Returns: true if the reaction was stopped, false if the reaction is not supported.

Stops playing a reaction that was started using MyAvatar.beginReaction.

Parameters

Name Type Description
reactionName string

The reaction to stop playing.

(static) endSit( position, rotation )

Ends a sitting action for the avatar.

Parameters

Name Type Description
position Vec3

The position of the avatar when standing up.

rotation Quat

The orientation of the avatar when standing up.

(static) getAbsoluteDefaultJointRotationInObjectFrame( index ) → {Quat}
Returns: The default rotation of the joint in avatar coordinates.

Gets the default joint rotations in avatar coordinates. The default pose of the avatar is defined by the position and orientation of all bones in the avatar's model file. Typically this is a T-pose.

Parameters

Name Type Description
index number

The joint index.

Example

Report the default rotation of your avatar's head joint relative to your avatar.

var headIndex = MyAvatar.getJointIndex("Head");
var defaultHeadRotation = MyAvatar.getAbsoluteDefaultJointRotationInObjectFrame(headIndex);
print("Default head rotation: " + JSON.stringify(Quat.safeEulerAngles(defaultHeadRotation))); // Degrees
(static) getAbsoluteDefaultJointTranslationInObjectFrame( index ) → {Vec3}
Returns: The default position of the joint in avatar coordinates.

Gets the default joint translations in avatar coordinates. The default pose of the avatar is defined by the position and orientation of all bones in the avatar's model file. Typically this is a T-pose.

Parameters

Name Type Description
index number

The joint index.

Example

Report the default translation of your avatar's head joint relative to your avatar.

var headIndex = MyAvatar.getJointIndex("Head");
var defaultHeadTranslation = MyAvatar.getAbsoluteDefaultJointTranslationInObjectFrame(headIndex);
print("Default head translation: " + JSON.stringify(defaultHeadTranslation));
(static) getAbsoluteJointRotationInObjectFrame( index ) → {Quat}
Returns: The rotation of the joint relative to the avatar.

Gets the rotation of a joint relative to the avatar.

Parameters

Name Type Description
index number

The index of the joint.

Example

Report the rotation of your avatar's head joint relative to your avatar.

var headIndex = MyAvatar.getJointIndex("Head");
var headRotation = MyAvatar.getAbsoluteJointRotationInObjectFrame(headIndex);
print("Head rotation: " + JSON.stringify(Quat.safeEulerAngles(headRotation))); // Degrees
(static) getAbsoluteJointTranslationInObjectFrame( index ) → {Vec3}
Returns: The translation of the joint relative to the avatar.

Gets the translation of a joint relative to the avatar.

Parameters

Name Type Description
index number

The index of the joint.

Example

Report the translation of your avatar's head joint relative to your avatar.

var headIndex = MyAvatar.getJointIndex("Head");
var headTranslation = MyAvatar.getAbsoluteJointTranslationInObjectFrame(headIndex);
print("Head translation: " + JSON.stringify(headTranslation));
(static) getAcceleration( ) → {Vec3}
Returns: The current acceleration of the avatar.

Gets the current acceleration of the avatar.

(static) getAnimationRoles( ) → {Array.<string>}
Returns: Array of role strings.

Gets the current animation roles.

Each avatar has an avatar-animation.json file that defines which animations are used and how they are blended together with procedural data (such as look at vectors, hand sensors etc.). Each animation specified in the avatar-animation.json file is known as an animation role. Animation roles map to easily understandable actions that the avatar can perform, such as "idleStand", "idleTalk", or "walkFwd". getAnimationRoles() is used get the list of animation roles defined in the avatar-animation.json.

Example

Print the list of animation roles defined in the avatar's avatar-animation.json file to the debug log.

var roles = MyAvatar.getAnimationRoles();
print("Animation Roles:");
for (var i = 0; i < roles.length; i++) {
    print(roles[i]);
}
(static) getAnimGraphOverrideUrl( ) → {string}
Returns: The URL of the override animation graph JSON file. "" if there is no override animation graph.

Gets the URL of the override animation graph.

See Custom Avatar Animations for information on animation graphs.

(static) getAnimGraphUrl( ) → {string}
Returns: The URL of the current animation graph JSON file.

Gets the URL of animation graph (i.e., the avatar animation JSON) that's currently being used for avatar animations.

See Custom Avatar Animations for information on animation graphs.

Example

Report the current avatar animation JSON being used.

print(MyAvatar.getAnimGraphUrl());
(static) getAttachmentData( ) → {Array.<AttachmentData>}
Returns: Information about all models attached to your avatar.

Gets information about the models currently attached to your avatar.

Deprecated: This function is deprecated and will be removed. Use avatar entities instead.

Example

Report the URLs of all current attachments.

var attachments = MyAvatar.getaAttachmentData();
for (var i = 0; i < attachments.length; i++) {
    print(attachments[i].modelURL);
}

// Note: If using from the Avatar API, replace "MyAvatar" with "Avatar".
(static) getAttachmentsVariant( ) → {Array.<AttachmentData>}
Returns: Information about all models attached to your avatar.

Gets information about the models currently attached to your avatar.

Deprecated: This function is deprecated and will be removed. Use avatar entities instead.

(static) getAvatarEntitiesVariant( ) → {Array.<MyAvatar.AvatarEntityData>}
Returns: The current avatar entity IDs and their properties.

Gets the current avatar entity IDs and their properties.

(static) getAvatarEntityData( ) → {AvatarEntityMap}
Returns: Details of all avatar entities.

Gets details of all avatar entities.

Warning: Potentially an expensive call. Do not use if possible.

Example

Report the current avatar entities.

var avatarEntityData = MyAvatar.getAvatarEntityData();
print("Avatar entities: " + JSON.stringify(avatarEntityData));
(static) getAvatarScale( ) → {number}
Returns: The target scale for the avatar, range 0.0051000.0.

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.

(static) getBeginEndReactions( ) → {Array.<string>}
Returns: List of reaction names that can be enabled using MyAvatar.beginReaction and MyAvatar.endReaction.

Gets the list of reactions names that can be enabled using MyAvatar.beginReaction and MyAvatar.endReaction.

See also: MyAvatar.getTriggerReactions.

Example

List the available begin-end reactions.

print("Begin-end reactions:", JSON.stringify(MyAvatar.getBeginEndReactions()));
(static) getCenterOfGravityModelEnabled( ) → {boolean}
Returns: true if the hips are being balanced over the feet, false if the hips are being positioned under the head.

Gets whether the avatar hips are being balanced over the feet or placed under the head.

(static) getCharacterControllerEnabled( ) → {boolean}
Returns: true if the avatar will currently collide with entities, false if it won't.

Deprecated: This function is deprecated and will be removed. Use MyAvatar.getCollisionsEnabled instead.

(static) getCollidingFlowJoints( ) → {Array.<number>}
Returns: The indexes of currently colliding flow joints.

Gets the indexes of currently colliding flow joints.

(static) getCollisionCapsule( ) → {MyAvatar.CollisionCapsule}
Returns: The avatar's collision capsule.

Gets the avatar's collision capsule: a cylinder with hemispherical ends that approximates the extents or the avatar.

Warning: The values returned are in world coordinates but aren't necessarily up to date with the avatar's current position.

(static) getCollisionsEnabled( ) → {boolean}
Returns: true if the avatar will currently collide with entities, false if it won't.

Gets whether the avatar will currently collide with entities.

Note: The avatar will always collide with entities if in a zone that disallows collisionless avatars.

(static) getControllerLeftHandMatrix( ) → {Mat4}
Returns: The rotation and translation of the left hand controller relative to the avatar.

Gets the rotation and translation of the left hand controller relative to the avatar.

Example

Report the left hand controller matrix.

var leftHandMatrix = MyAvatar.getControllerLeftHandMatrix();
print("Controller left hand matrix: " + JSON.stringify(leftHandMatrix));
print("Rotation: " + JSON.stringify(Mat4.extractRotation(leftHandMatrix)));
print("Translation: " + JSON.stringify(Mat4.extractTranslation(leftHandMatrix)));
print("Scale: " + JSON.stringify(Mat4.extractScale(leftHandMatrix))); // Always 1,1,1.

// Note: If using from the Avatar API, replace "MyAvatar" with "Avatar".
(static) getControllerRightHandMatrix( ) → {Mat4}
Returns: The rotation and translation of the right hand controller relative to the avatar.

Gets the rotation and translation of the right hand controller relative to the avatar.

(static) getControlScheme( ) → {MyAvatar.LocomotionControlsMode}
Returns: The control scheme that is in use.

Gets the control scheme that is in use.

(static) getDataRate( rateNameopt ) → {number}
Returns: The data rate in kbps.

Gets the amount of avatar mixer data being generated by the avatar.

Parameters

Name Type Attributes Default Value Description
rateName AvatarDataRate <optional>
""

The type of avatar mixer data to get the data rate of.

(static) getDefaultEyePosition( ) → {Vec3}
Returns: Default position between your avatar's eyes in world coordinates.

Gets the position in world coordinates of the point directly between your avatar's eyes assuming your avatar was in its default pose. This is a reference position; it does not change as your avatar's head moves relative to the avatar position.

Example

Report your avatar's default eye position.

var defaultEyePosition = MyAvatar.getDefaultEyePosition();
print(JSON.stringify(defaultEyePosition));
(static) getDefaultJointRotation( index ) → {Quat}
Returns: The default rotation of the joint if the joint index is valid, otherwise Quat.IDENTITY.

Gets the default rotation of a joint (in the current avatar) relative to its parent.

For information on the joint hierarchy used, see Avatar Standards.

Parameters

Name Type Description
index number

The joint index.

(static) getDefaultJointTranslation( index ) → {Vec3}
Returns: The default translation of the joint (in model coordinates) if the joint index is valid, otherwise Vec3.ZERO.

Gets the default translation of a joint (in the current avatar) relative to its parent, in model coordinates.

Warning: These coordinates are not necessarily in meters.

For information on the joint hierarchy used, see Avatar Standards.

Parameters

Name Type Description
index number

The joint index.

(static) getDomainMaxScale( ) → {number}
Returns: The maximum scale allowed for this avatar in the current domain.

Gets the maximum scale allowed for this avatar in the current domain. This value can change as the user changes avatars or when changing domains.

(static) getDomainMinScale( ) → {number}
Returns: The minimum scale allowed for this avatar in the current domain.

Gets the minimum scale allowed for this avatar in the current domain. This value can change as the user changes avatars or when changing domains.

(static) getDominantHand( ) → {string}
Returns: "left" for the left hand, "right" for the right hand.

Gets the avatar's dominant hand.

(static) getDriveGear1( ) → {number}
Returns: Value between [0.0, 1.0].

Get the first 'shifting point' for acceleration step function.

(static) getDriveGear2( ) → {number}
Returns: Value between [0.0, 1.0].

Get the second 'shifting point' for acceleration step function.

(static) getDriveGear3( ) → {number}
Returns: Value between [0.0, 1.0].

Get the third 'shifting point' for acceleration step function.

(static) getDriveGear4( ) → {number}
Returns: Value between [0.0, 1.0].

Get the fourth 'shifting point' for acceleration step function.

(static) getDriveGear5( ) → {number}
Returns: Value between [0.0, 1.0].

Get the fifth 'shifting point' for acceleration step function.

(static) getEnableMeshVisible( ) → {boolean}
Returns: true if your avatar's mesh is visible, otherwise false.

Gets whether your avatar mesh is visible.

(static) getEyeHeight( ) → {number}
Returns: The eye height of the avatar.

Gets the current eye height of the avatar. This height is only an estimate and might be incorrect for avatars that are missing standard joints.

(static) getEyePosition( ) → {Vec3}
Returns: The current position of the point directly between the avatar's eyes.

Gets the current position of the point directly between the avatar's eyes.

Example

Report your avatar's current eye position.

var eyePosition = MyAvatar.getEyePosition();
print(JSON.stringify(eyePosition));
(static) getEyesLookAt( ) → {Vec3}
Returns: The eyes' look-at target in world coordinates.

Gets the current target point of the eyes look direction in world coordinates.

(static) getFlowData( ) → {MyAvatar.FlowData}
Returns: MyAvatar.FlowData

Gets the current flow configuration.

(static) getFlyingDesktopPref( ) → {boolean}
Returns: true if your preference is to enable flying in desktop display mode, otherwise false.

Gets your preference for flying in desktop display mode. Note that your ability to fly also depends on whether the domain you're in allows you to fly.

(static) getFlyingEnabled( ) → {boolean}
Returns: true if your preference is to enable flying in your current desktop or HMD display mode, otherwise false.

Gets your preference for flying in your current desktop or HMD display mode. Note that your ability to fly also depends on whether the domain you're in allows you to fly.

(static) getFlyingHMDPref( ) → {boolean}
Returns: true if your preference is to enable flying in HMD display mode, otherwise false.

Gets your preference for flying in HMD display mode. Note that your ability to fly also depends on whether the domain you're in allows you to fly.

(static) getFullAvatarModelName( ) → {string}
Returns: The full avatar model name.

Gets the full avatar model name for the current avatar.

Example

Report the current full avatar model name.

print(MyAvatar.getFullAvatarModelName());
(static) getFullAvatarURLFromPreferences( ) → {string}
Returns: The full avatar model name.

Gets the complete URL for the current avatar.

Example

Report the URL for the current avatar.

print(MyAvatar.getFullAvatarURLFromPreferences());
(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 -5 m/s2.

(static) getHandRelativeMovement( ) → {number}
Returns: true if your preference is for user locomotion to be relative to the direction your controller is pointing, otherwise false.

Get your preference for hand-relative movement.

(static) getHandState( ) → {HandState}
Returns: The pointing state of the hand.

Gets the pointing state of the hands to control where the laser emanates from. If the right index finger is pointing, the laser emanates from the tip of that finger, otherwise it emanates from the palm.

(static) getHeadDeltaPitch( ) → {number}
Returns: The pitch that the avatar's head should be if a face tracker is connected and being used, otherwise 0, in degrees.

If a face tracker is connected and being used, gets the estimated pitch of the user's head scaled. This is scale such that the avatar looks at the edge of the view frustum when the user looks at the edge of their screen.

(static) getHeadFinalPitch( ) → {number}
Returns: The pitch of the avatar's head, in degrees.

Gets the pitch of the avatar's head relative to its body.

(static) getHeadFinalRoll( ) → {number}
Returns: The roll of the avatar's head, in degrees.

Gets the roll of the avatar's head relative to its body.

(static) getHeadFinalYaw( ) → {number}
Returns: The yaw of the avatar's head, in degrees.

Gets the yaw of the avatar's head relative to its body.

(static) getHeadLookAt( ) → {Vec3}
Returns: The head's look-at target in world coordinates.

Gets the current target point of the head's look direction in world coordinates.

(static) getHeadPosition( ) → {Vec3}
Returns: The current position of the avatar's "Head" joint.

Gets the current position of the avatar's "Head" joint.

Example

Report the current position of your avatar's head.

print(JSON.stringify(MyAvatar.getHeadPosition()));
(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.

(static) getHmdAvatarAlignmentType( ) → {string}
Returns: "head" if aligning your head and your avatar's head, "eyes" if aligning your eyes and your avatar's eyes.

Gets the HMD alignment relative to your avatar.

(static) getHMDLeanRecenterEnabled( ) → {boolean}
Returns: true if recentering is enabled, false if not.

Gets whether the avatar's position updates to recenter the avatar under the head. In room-scale VR, recentering causes your avatar to follow your HMD as you walk around the room.

(static) getIKErrorOnLastSolve( ) → {number}
Returns: The maximum IK error distance.

Gets the maximum error distance from the most recent inverse kinematics (IK) solution.

(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, or Avatar.getJointNames if using the Avatar API.

Parameters

Name Type Description
name string

The name of the joint.

Example

Report the index of your avatar's left arm joint.

print(JSON.stringify(MyAvatar.getJointIndex("LeftArm")));

// Note: If using from the Avatar API, replace "MyAvatar" with "Avatar".
(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.

print(JSON.stringify(MyAvatar.getJointNames()));

// Note: If using from the Avatar API, replace "MyAvatar" with "Avatar".
(static) getJointPosition( index ) → {Vec3}
Returns: The position of the joint in world coordinates.

Gets the position of a joint in the current avatar.

Parameters

Name Type Description
index number

The index of the joint.

(static) getJointPosition( name ) → {Vec3}
Returns: The position of the joint in world coordinates.

Gets the position of a joint in the current avatar.

Parameters

Name Type Description
name string

The name of the joint.

Example

Report the position of your avatar's hips.

print(JSON.stringify(MyAvatar.getJointPosition("Hips")));
(static) getJointRotation( index ) → {Quat}
Returns: The rotation of the joint relative to its parent.

Gets the rotation of a joint relative to its parent. For information on the joint hierarchy used, see Avatar Standards.

Parameters

Name Type Description
index number

The index of the joint.

(static) getJointRotation( name ) → {Quat}
Returns: The rotation of the joint relative to its parent.

Gets the rotation of a joint relative to its parent. For information on the joint hierarchy used, see Avatar Standards.

Parameters

Name Type Description
name string

The name of the joint.

Example

Report the rotation of your avatar's hips joint.

print(JSON.stringify(MyAvatar.getJointRotation("Hips")));

// Note: If using from the Avatar API, replace "MyAvatar" with "Avatar".
(static) getJointRotations( ) → {Array.<Quat>}
Returns: The rotations of all joints relative to each's parent. The values are in the same order as the array returned by MyAvatar.getJointNames, or Avatar.getJointNames if using the Avatar API.

Gets the rotations of all joints in the current avatar. Each joint's rotation is relative to its parent joint.

Example

Report the rotations of all your avatar's joints.

print(JSON.stringify(MyAvatar.getJointRotations()));

// Note: If using from the Avatar API, replace all "MyAvatar" with "Avatar".
(static) getJointTranslation( index ) → {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.

For information on the joint hierarchy used, see Avatar Standards.

Parameters

Name Type Description
index number

The index of the joint.

(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.

For information on the joint hierarchy used, see Avatar Standards.

Parameters

Name Type Description
name number

The name of the joint.

Example

Report the translation of your avatar's hips joint.

print(JSON.stringify(MyAvatar.getJointRotation("Hips")));

// Note: If using from the Avatar API, replace "MyAvatar" with "Avatar".
(static) getJointTranslations( ) → {Array.<Vec3>}
Returns: The translations of all joints relative to each's parent, in model coordinates. The values are in the same order as the array returned by MyAvatar.getJointNames, or Avatar.getJointNames if using the Avatar API.

Gets the translations of all joints in the current avatar. Each joint's translation is relative to its parent joint, in model coordinates.

Warning: These coordinates are not necessarily in meters.

(static) getLeftHandPose( ) → {Pose}
Returns: The pose of the avatar's left hand, relative to the avatar, as positioned by a hand controller.

Gets the pose (position, rotation, velocity, and angular velocity) of the avatar's left hand as positioned by a hand controller (e.g., Oculus Touch or Vive).

Note: The Leap Motion isn't part of the hand controller input system. (Instead, it manipulates the avatar's joints for hand animation.) If you are using the Leap Motion, the return value's valid property will be false and any pose values returned will not be meaningful.

Example

Report the pose of your avatar's left hand.

print(JSON.stringify(MyAvatar.getLeftHandPose()));
(static) getLeftHandPosition( ) → {Vec3}
Returns: The position of the left hand in avatar coordinates if positioned by a hand controller, otherwise Vec3.ZERO.

Gets the position of the avatar's left hand, relative to the avatar, as positioned by a hand controller (e.g., Oculus Touch or Vive).

Note: The Leap Motion isn't part of the hand controller input system. (Instead, it manipulates the avatar's joints for hand animation.)

Example

Report the position of your left hand relative to your avatar.

print(JSON.stringify(MyAvatar.getLeftHandPosition()));
(static) getLeftHandTipPose( ) → {Pose}
Returns: The pose of the avatar's left hand, relative to the avatar, as positioned by a hand controller, and translated 0.3m along the palm.

Gets the pose (position, rotation, velocity, and angular velocity) of the avatar's left hand, relative to the avatar, as positioned by a hand controller (e.g., Oculus Touch or Vive), and translated 0.3m along the palm.

Note: Leap Motion isn't part of the hand controller input system. (Instead, it manipulates the avatar's joints for hand animation.) If you are using Leap Motion, the return value's valid property will be false and any pose values returned will not be meaningful.

(static) getLeftHandTipPosition( ) → {Vec3}
Returns: The position 0.3m in front of the left hand's position in the direction along the palm, in avatar coordinates. If the hand isn't being positioned by a controller, Vec3.ZERO is returned.

Gets the position 0.3m in front of the left hand's position in the direction along the palm, in avatar coordinates, as positioned by a hand controller.

(static) getLeftPalmPosition( ) → {Vec3}
Returns: The position of the left palm in world coordinates.

Gets the position of the left palm in world coordinates.

Example

Report the position of your avatar's left palm.

print(JSON.stringify(MyAvatar.getLeftPalmPosition()));
(static) getLeftPalmRotation( ) → {Quat}
Returns: The rotation of the left palm in world coordinates.

Gets the rotation of the left palm in world coordinates.

Example

Report the rotation of your avatar's left palm.

print(JSON.stringify(MyAvatar.getLeftPalmRotation()));
(static) getNeckPosition( ) → {Vec3}
Returns: The position of the neck in world coordinates.

Gets the position of the current avatar's neck in world coordinates.

Example

Report the position of your avatar's neck.

print(JSON.stringify(MyAvatar.getNeckPosition()));
(static) getOrientationForAudio( ) → {Quat}
Returns: The orientation of your listening position.

Gets the orientation of your listening position for spatialized audio. The orientation depends on the value of the audioListenerMode property.

(static) getOrientationVar( ) → {object}
Returns: The avatar's orientation.

Gets the avatar orientation. Suitable for use in QML.

(static) getOtherAvatarsCollisionsEnabled( ) → {boolean}
Returns: true if the avatar will collide with other avatars, false if it won't.

Gets whether the avatar will collide with other avatars.

(static) getParentID( ) → {Uuid}
Returns: The ID of the entity or avatar that the avatar is parented to. Uuid.NULL if not parented.

Gets the ID of the entity or avatar that the avatar is parented to.

(static) getParentJointIndex( ) → {number}
Returns: The joint of the entity or avatar that the avatar is parented to. 65535 or -1 if parented to the entity or avatar's position and orientation rather than a joint.

Gets the joint of the entity or avatar that the avatar is parented to.

(static) getPositionForAudio( ) → {Vec3}
Returns: Your listening position.

Gets your listening position for spatialized audio. The position depends on the value of the audioListenerMode property.

(static) getRawDriveKey( key ) → {number}
Returns: The value of the drive key.

Gets the value of a drive key, regardless of whether it is disabled.

Parameters

Name Type Description
key DriveKey

The drive key.

(static) getRightHandPose( ) → {Pose}
Returns: The pose of the avatar's right hand, relative to the avatar, as positioned by a hand controller.

Gets the pose (position, rotation, velocity, and angular velocity) of the avatar's left hand as positioned by a hand controller (e.g., Oculus Touch or Vive).

Note: The Leap Motion isn't part of the hand controller input system. (Instead, it manipulates the avatar's joints for hand animation.) If you are using the Leap Motion, the return value's valid property will be false and any pose values returned will not be meaningful.

Example

Report the pose of your avatar's right hand.

print(JSON.stringify(MyAvatar.getRightHandPose()));
(static) getRightHandPosition( ) → {Vec3}
Returns: The position of the right hand in avatar coordinates if positioned by a hand controller, otherwise Vec3.ZERO.

Gets the position of the avatar's right hand, relative to the avatar, as positioned by a hand controller (e.g., Oculus Touch or Vive).

Note: The Leap Motion isn't part of the hand controller input system. (Instead, it manipulates the avatar's joints for hand animation.)

Example

Report the position of your right hand relative to your avatar.

print(JSON.stringify(MyAvatar.getLeftHandPosition()));
(static) getRightHandTipPose( ) → {Pose}
Returns: The pose of the avatar's right hand, relative to the avatar, as positioned by a hand controller, and translated 0.3m along the palm.

Gets the pose (position, rotation, velocity, and angular velocity) of the avatar's right hand, relative to the avatar, as positioned by a hand controller (e.g., Oculus Touch or Vive), and translated 0.3m along the palm.

Note: Leap Motion isn't part of the hand controller input system. (Instead, it manipulates the avatar's joints for hand animation.) If you are using Leap Motion, the return value's valid property will be false and any pose values returned will not be meaningful.

(static) getRightHandTipPosition( ) → {Vec3}
Returns: The position 0.3m in front of the right hand's position in the direction along the palm, in avatar coordinates. If the hand isn't being positioned by a controller, Vec3.ZERO is returned.

Gets the position 0.3m in front of the right hand's position in the direction along the palm, in avatar coordinates, as positioned by a hand controller.

(static) getRightPalmPosition( ) → {Vec3}
Returns: The position of the right palm in world coordinates.

Gets the position of the right palm in world coordinates.

Example

Report the position of your avatar's right palm.

print(JSON.stringify(MyAvatar.getRightPalmPosition()));
(static) getRightPalmRotation( ) → {Quat}
Returns: The rotation of the right palm in world coordinates.

Get the rotation of the right palm in world coordinates.

Example

Report the rotation of your avatar's right palm.

print(JSON.stringify(MyAvatar.getRightPalmRotation()));
(static) getSensorToWorldMatrix( ) → {Mat4}
Returns: The scale, rotation, and translation transform from the user's real world to the avatar's size, orientation, and position in the virtual world.

Gets the transform from the user's real world to the avatar's size, orientation, and position in the virtual world.

Example

Report the sensor to world matrix.

var sensorToWorldMatrix = MyAvatar.getSensorToWorldMatrix();
print("Sensor to woprld matrix: " + JSON.stringify(sensorToWorldMatrix));
print("Rotation: " + JSON.stringify(Mat4.extractRotation(sensorToWorldMatrix)));
print("Translation: " + JSON.stringify(Mat4.extractTranslation(sensorToWorldMatrix)));
print("Scale: " + JSON.stringify(Mat4.extractScale(sensorToWorldMatrix)));

// Note: If using from the Avatar API, replace "MyAvatar" with "Avatar".
(static) getSensorToWorldScale( ) → {number}
Returns: The scale that transforms dimensions in the user's real world to the avatar's size in the virtual world.

Gets the scale that transforms dimensions in the user's real world to the avatar's size in the virtual world.

(static) getSimulationRate( rateNameopt ) → {number}
Returns: Simulation rate in Hz.

Deprecated: This function is deprecated and will be removed.

Parameters

Name Type Attributes Default Value Description
rateName AvatarSimulationRate <optional>
""

Rate name.

(static) getSkeleton( ) → {Array.<SkeletonJoint>}
Returns: Information about each joint in the avatar's skeleton.

Gets information on all the joints in the avatar's skeleton.

(static) getSkeletonOffset( ) → {Vec3}
Returns: The current skeleton offset.

Gets the offset applied to the current avatar. The offset adjusts the position that the avatar is rendered. For example, with an offset of { x: 0, y: 0.1, z: 0 }, your avatar will appear to be raised off the ground slightly.

Example

Report your avatar's current skeleton offset.

print(JSON.stringify(MyAvatar.getSkeletonOffset());
(static) getSnapTurn( ) → {boolean}
Returns: true if you do snap turns in HMD mode; false if you do smooth turns in HMD mode.

Gets whether you do snap turns in HMD mode.

(static) getStrafeEnabled( ) → {boolean}
Returns: true if strafing is enabled, false if it isn't.

Gets whether strafing is enabled.

(static) getTargetAvatar( ) → {ScriptAvatar}
Returns: Information on the avatar being looked at, null if no avatar is being looked at.

Gets information on the avatar your avatar is currently looking at.

(static) getTargetAvatarPosition( ) → {Vec3}
Returns: The position of the avatar beeing looked at.

Gets the position of the avatar your avatar is currently looking at.

Example

Report the position of the avatar you're currently looking at.

print(JSON.stringify(MyAvatar.getTargetAvatarPosition()));
(static) getTargetScale( ) → {number}
Returns: The target scale of the avatar.

Gets the target scale of the avatar without any restrictions on permissible values imposed by the domain. In contrast, the scale property's value may be limited by the domain's settings.

Example

Compare the target and current avatar scales.

print("Current avatar scale: " + MyAvatar.scale);
print("Target avatar scale:  " + MyAvatar.getTargetScale());

// Note: If using from the Avatar API, replace all occurrences of "MyAvatar" with "Avatar".
(static) getThrust( ) → {Vec3}
Returns: The thrust currently being applied to your avatar.

Gets the thrust currently being applied to your avatar.

Deprecated: This function is deprecated and will be removed. Use MyAvatar.motorVelocity and related properties instead.

(static) getTriggerReactions( ) → {Array.<string>}
Returns: List of reaction names that can be triggered using MyAvatar.triggerReaction.

Gets the list of reactions names that can be triggered using MyAvatar.triggerReaction.

See also: MyAvatar.getBeginEndReactions.

Example

List the available trigger reactions.

print("Trigger reactions:", JSON.stringify(MyAvatar.getTriggerReactions()));
(static) getUpdateRate( rateNameopt ) → {number}
Returns: The update rate in Hz.

Gets the update rate of avatar mixer data being generated by the avatar.

Parameters

Name Type Attributes Default Value Description
rateName AvatarUpdateRate <optional>
""

The type of avatar mixer data to get the update rate of.

(static) getWorldFeetPosition( ) → {Vec3}
Returns: The position of the avatar's feet in world coordinates.

Gets the position of the current avatar's feet (or rather, bottom of its collision capsule) in world coordinates.

(static) goToFeetLocation( position, hasOrientationopt, orientationopt, shouldFaceLocationopt )

Moves the avatar to a new position and/or orientation in the domain, with safe landing, while taking into account avatar leg length.

Parameters

Name Type Attributes Default Value Description
position Vec3

The new position for the avatar, in world coordinates.

hasOrientation boolean <optional>
false

Set to true to set the orientation of the avatar.

orientation Quat <optional>
Quat.IDENTITY

The new orientation for the avatar.

shouldFaceLocation boolean <optional>
false

Set to true to position the avatar a short distance away from the new position and orientate the avatar to face the position.

(static) goToLocation( position, hasOrientationopt, orientationopt, shouldFaceLocationopt, withSafeLandingopt )

Moves the avatar to a new position and/or orientation in the domain.

Parameters

Name Type Attributes Default Value Description
position Vec3

The new position for the avatar, in world coordinates.

hasOrientation boolean <optional>
false

Set to true to set the orientation of the avatar.

orientation Quat <optional>
Quat.IDENTITY

The new orientation for the avatar.

shouldFaceLocation boolean <optional>
false

Set to true to position the avatar a short distance away from the new position and orientate the avatar to face the position.

withSafeLanding boolean <optional>
true

Set to false to disable safe landing when teleporting.

(static) goToLocation( target )

Moves the avatar to a new position and (optional) orientation in the domain, with safe landing.

Parameters

Name Type Description
target MyAvatar.GoToProperties

The goto target.

(static) goToLocationAndEnableCollisions( position )

Moves the avatar to a new position, with safe landing, and enables collisions.

Parameters

Name Type Description
position Vec3

The new position for the avatar, in world coordinates.

(static) grab( targetID, parentJointIndex, offset, rotationalOffset ) → {Uuid}
Returns: The ID of the new grab.

Creates a new grab that grabs an entity.

Parameters

Name Type Description
targetID Uuid

The ID of the entity to grab.

parentJointIndex number

The avatar joint to use to grab the entity.

offset Vec3

The target's local position relative to the joint.

rotationalOffset Quat

The target's local rotation relative to the joint.

Example

Create and grab an entity for a short while.

var entityPosition = Vec3.sum(MyAvatar.position, Vec3.multiplyQbyV(MyAvatar.orientation, { x: 0, y: 0, z: -5 }));
var entityRotation = MyAvatar.orientation;
var entityID = Entities.addEntity({
    type: "Box",
    position: entityPosition,
    rotation: entityRotation,
    dimensions: { x: 0.5, y: 0.5, z: 0.5 }
});
var rightHandJoint = MyAvatar.getJointIndex("RightHand");
var relativePosition = Entities.worldToLocalPosition(entityPosition, MyAvatar.SELF_ID, rightHandJoint);
var relativeRotation = Entities.worldToLocalRotation(entityRotation, MyAvatar.SELF_ID, rightHandJoint);
var grabID = MyAvatar.grab(entityID, rightHandJoint, relativePosition, relativeRotation);

Script.setTimeout(function () {
    MyAvatar.releaseGrab(grabID);
    Entities.deleteEntity(entityID);
}, 10000);
(static) hoverWhenUnsupported( ) → {boolean}
Returns: true if your avatar hovers when its feet are not on the ground, false if it falls.

Gets whether your avatar hovers when its feet are not on the ground.

(static) increaseSize( )

Increases the avatar's scale by five percent, up to a minimum scale of 1000.

Example

Reset your avatar's size to default then grow it 5 times.

MyAvatar.resetSize();

for (var i = 0; i < 5; i++){
    print("Growing by 5 percent");
    MyAvatar.increaseSize();
}
(static) isDown( direction ) → {boolean}
Returns: true if the direction vector is pointing generally in the direction of the avatar's "down" direction.

Tests whether a vector is pointing in the general direction of the avatar's "down" direction (i.e., dot product of vectors is < 0).

Parameters

Name Type Description
direction Vec3

The vector to test.

(static) isDriveKeyDisabled( key ) → {boolean}
Returns: true if the drive key is disabled, false if it isn't.

Checks whether a drive key is disabled.

Parameters

Name Type Description
key DriveKey

The drive key to check.

(static) isFlying( ) → {boolean}
Returns: true if your avatar is flying and not taking off or falling, false if not.

Checks whether your avatar is flying.

(static) isInAir( ) → {boolean}
Returns: true if your avatar is taking off, flying, or falling, otherwise false because your avatar is on the ground.

Checks whether your avatar is in the air.

(static) isJointDataValid( index ) → {boolean}
Returns: true if the joint data are valid, false if not.

Checks that the data for a joint are valid.

Parameters

Name Type Description
index number

The index of the joint.

(static) isJointDataValid( name ) → {boolean}
Returns: true if the joint data are valid, false if not.

Checks if the data for a joint are valid.

Parameters

Name Type Description
name string

The name of the joint.

(static) isRecenteringHorizontally( ) → {boolean}
Returns: true if the avatar is keeping its center of gravity under its head position, false if not.

Gets whether the avatar is configured to keep its center of gravity under its head.

(static) isSeated( ) → {boolean}
Returns: true if the avatar is in a seated pose, false if it isn't.

Gets whether the avatar is in a seated pose. The seated pose is set by calling MyAvatar.beginSit.

(static) isUp( direction ) → {boolean}
Returns: true if the direction vector is pointing generally in the direction of the avatar's "up" direction.

Tests whether a vector is pointing in the general direction of the avatar's "up" direction (i.e., dot product of vectors is > 0).

Parameters

Name Type Description
direction Vec3

The vector to test.

(static) jointToWorldDirection( direction, jointIndexopt ) → {Vec3}
Returns: The direction in world coordinates.

Transforms a direction in a joint's coordinates, or avatar coordinates if no joint is specified, to a direction in world coordinates.

Parameters

Name Type Attributes Default Value Description
direction Vec3

The direction in joint coordinates, or avatar coordinates if no joint is specified.

jointIndex number <optional>
-1

The index of the joint.

(static) jointToWorldPoint( position, jointIndexopt ) → {Vec3}
Returns: The position in world coordinates.

Transforms a position in a joint's coordinates, or avatar coordinates if no joint is specified, to a position in world coordinates.

Parameters

Name Type Attributes Default Value Description
position Vec3

The position in joint coordinates, or avatar coordinates if no joint is specified.

jointIndex number <optional>
-1

The index of the joint.

(static) jointToWorldRotation( rotation, jointIndexopt ) → {Quat}
Returns: The rotation in world coordinates.

Transforms a rotation in a joint's coordinates, or avatar coordinates if no joint is specified, to a rotation in world coordinates.

Parameters

Name Type Attributes Default Value Description
rotation Quat

The rotation in joint coordinates, or avatar coordinates if no joint is specified.

jointIndex number <optional>
-1

The index of the joint.

(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.). overrideAnimation() is used to completely override all motion from the default animation system (including inverse kinematics for hand and head controllers) and play a set of specified animations. To end these animations and restore the default animations, use MyAvatar.restoreAnimation.

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. For more information about avatar joint orientation standards, see Avatar Standards.

Parameters

Name Type Description
url string

The URL to the animation file. Animation files may be in glTF or FBX format, but only need to contain the avatar skeleton and animation data. glTF models may be in JSON or binary format (".gltf" or ".glb" URLs respectively).

Warning: glTF animations currently do not always animate correctly.

fps number

The frames per second (FPS) rate for the animation playback. 30 FPS is normal speed.

loop boolean

true if the animation should loop, false if it shouldn't.

firstFrame number

The frame to start the animation at.

lastFrame number

The frame to end the animation at.

Example

Play a clapping animation on your avatar for three seconds.

var ANIM_URL = "https://apidocs.vircadia.dev/models/ClapHands_Standing.fbx";
MyAvatar.overrideAnimation(ANIM_URL, 30, true, 0, 53);
Script.setTimeout(function () {
    MyAvatar.restoreAnimation();
    MyAvatar.clearIKJointLimitHistory();
}, 3000);
(static) overrideHandAnimation( isLeft, url, fps, loop, firstFrame, lastFrame )

Overrides the default hand poses that are triggered with controller buttons. Use MyAvatar.restoreHandAnimation to restore the default poses.

Parameters

Name Type Description
isLeft boolean

true to override the left hand, false to override the right hand.

url string

The URL of the animation file. Animation files need to be in glTF or FBX format, but only need to contain the avatar skeleton and animation data. glTF models may be in JSON or binary format (".gltf" or ".glb" URLs respectively).

Warning: glTF animations currently do not always animate correctly.

fps number

The frames per second (FPS) rate for the animation playback. 30 FPS is normal speed.

loop boolean

true if the animation should loop, false if it shouldn't.

firstFrame number

The frame to start the animation at.

lastFrame number

The frame to end the animation at.

Example

Override left hand animation for three seconds.

var ANIM_URL = "https://apidocs.vircadia.dev/models/ClapHands_Standing.fbx";
MyAvatar.overrideHandAnimation(isLeft, ANIM_URL, 30, true, 0, 53);
Script.setTimeout(function () {
    MyAvatar.restoreHandAnimation();
}, 3000);
(static) overrideRoleAnimation( role, url, fps, loop, firstFrame, lastFrame )

Overrides a specific animation role.

Each avatar has an avatar-animation.json file that defines a set of animation roles. Animation roles map to easily understandable actions that the avatar can perform, such as "idleStand", "idleTalk", or "walkFwd". To get the full list of roles, use {@ link MyAvatar.getAnimationRoles}. For each role, the avatar-animation.json defines when the animation is used, the animation clip (glTF or FBX) used, and how animations are blended together with procedural data (such as look at vectors, hand sensors etc.). overrideRoleAnimation() is used to change the animation clip (glTF or FBX) associated with a specified animation role. To end the role animation and restore the default, use MyAvatar.restoreRoleAnimation.

Note: Hand roles only affect the hand. Other "main" roles, like "idleStand", "idleTalk", and "takeoffStand", are full body.

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. For more information about avatar joint orientation standards, see Avatar Standards.

Parameters

Name Type Description
role string

The animation role to override

url string

The URL to the animation file. Animation files need to be in glTF or FBX format, but only need to contain the avatar skeleton and animation data. glTF models may be in JSON or binary format (".gltf" or ".glb" URLs respectively).

Warning: glTF animations currently do not always animate correctly.

fps number

The frames per second (FPS) rate for the animation playback. 30 FPS is normal speed.

loop boolean

true if the animation should loop, false if it shouldn't.

firstFrame number

The frame the animation should start at.

lastFrame number

The frame the animation should end at.

Example

The default avatar-animation.json defines an "idleStand" animation role. This role specifies that when the avatar is not moving, an animation clip of the avatar idling with hands hanging at its side will be used. It also specifies that when the avatar moves, the animation will smoothly blend to the walking animation used by the "walkFwd" animation role. In this example, the "idleStand" role animation clip has been replaced with a clapping animation clip. Now instead of standing with its arms hanging at its sides when it is not moving, the avatar will stand and clap its hands. Note that just as it did before, as soon as the avatar starts to move, the animation will smoothly blend into the walk animation used by the "walkFwd" animation role.

// An animation of the avatar clapping its hands while standing. Restore default after 30s.
var ANIM_URL = "https://apidocs.vircadia.dev/models/ClapHands_Standing.fbx";
MyAvatar.overrideRoleAnimation("idleStand", ANIM_URL, 30, true, 0, 53);
Script.setTimeout(function () {
    MyAvatar.restoreRoleAnimation();
}, 30000);
(static) pinJoint( index, position, orientation ) → {boolean}
Returns: true if the joint was pinned, false if it wasn't.

Sets and locks a joint's position and orientation.

Note: Only works on the hips joint.

Parameters

Name Type Description
index number

The index of the joint.

position Vec3

The position of the joint in world coordinates.

orientation Quat

The orientation of the joint in world coordinates.

(static) releaseEyesLookAtControl( )

Returns control of the avatar's eyes to the engine, and releases control from API calls.

(static) releaseGrab( grabID )

Releases (deletes) a grab to stop grabbing an entity.

Parameters

Name Type Description
grabID Uuid

The ID of the grab to release.

(static) releaseHeadLookAtControl( )

Returns control of the avatar's head to the engine, and releases control from API calls.

(static) removeAnimationStateHandler( handler )

Removes an animation state handler function.

Parameters

Name Type Description
handler number

The ID of the animation state handler function to remove.

(static) requestDisableHandTouch( )

Requests that the hand touch effect is enabled for your avatar. Any resulting change in the status of the hand touch effect will be signaled by MyAvatar.shouldDisableHandTouchChanged.

The hand touch effect makes the avatar's fingers adapt to the shape of any object grabbed, creating the effect that it is really touching that object.

(static) requestEnableHandTouch( )

Requests that the hand touch effect is disabled for your avatar. Any resulting change in the status of the hand touch effect will be signaled by MyAvatar.shouldDisableHandTouchChanged.

The hand touch effect makes the avatar's fingers adapt to the shape of any object grabbed, creating the effect that it is really touching that object.

(static) resetLastSent( )

Deprecated: This function is deprecated and will be removed.

(static) resetSensorsAndBody( )

Resets the sensor positioning of your HMD (if in use) and recenters your avatar body and head.

(static) resetSize( )

Resets the avatar's scale back to the default scale of 1.0.

(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. restoreAnimation() is used to restore all motion from the default animation system including inverse kinematics for hand and head controllers. If you aren't currently playing an override animation, this function has no effect.

Example

Play a clapping animation on your avatar for three seconds.

var ANIM_URL = "https://apidocs.vircadia.dev/models/ClapHands_Standing.fbx";
MyAvatar.overrideAnimation(ANIM_URL, 30, true, 0, 53);
Script.setTimeout(function () {
    MyAvatar.restoreAnimation();
}, 3000);
(static) restoreHandAnimation( isLeft )

Restores the default hand animation state machine that is driven by the state machine in the avatar-animation JSON.

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. restoreHandAnimation() is used to restore the default hand poses. If you aren't currently playing an override hand animation, this function has no effect.

Parameters

Name Type Description
isLeft boolean

Set to true if using the left hand

Example

Override left hand animation for three seconds.

var ANIM_URL = "https://apidocs.vircadia.dev/models/ClapHands_Standing.fbx";
MyAvatar.overrideHandAnimation(isLeft, ANIM_URL, 30, true, 0, 53);
Script.setTimeout(function () {
    MyAvatar.restoreHandAnimation();
}, 3000);
(static) restoreRoleAnimation( role )

Restores a default role animation.

Each avatar has an avatar-animation.json file that defines a set of animation roles. Animation roles map to easily understandable actions that the avatar can perform, such as "idleStand", "idleTalk", or "walkFwd". To get the full list of roles, use MyAvatar.getAnimationRoles. For each role, the avatar-animation.json defines when the animation is used, the animation clip (glTF or FBX) used, and how animations are blended together with procedural data (such as look-at vectors, hand sensors etc.). You can change the animation clip (glTF or FBX) associated with a specified animation role using MyAvatar.overrideRoleAnimation. restoreRoleAnimation() is used to restore a specified animation role's default animation clip. If you have not specified an override animation for the specified role, this function has no effect.

Parameters

Name Type Description
role string

The animation role clip to restore.

(static) restrictScaleFromDomainSettings( domainSettings )

Deprecated: This function is deprecated and will be removed.

Parameters

Name Type Description
domainSettings object

Domain settings.

(static) rigReady( )

Deprecated: This function is deprecated and will be removed.

(static) rigReset( )

Deprecated: This function is deprecated and will be removed.

(static) safeLanding( position ) → {boolean}
Returns: true if the avatar was moved, false if it wasn't.

Deprecated: This function is deprecated and will be removed.

Parameters

Name Type Description
position Vec3

The new position for the avatar, in world coordinates.

(static) sanitizeAvatarEntityProperties( properties )

Deprecated: This function is deprecated and will be removed.

Parameters

Name Type Description
properties EntityItemProperties

Properties.

(static) sendAvatarDataPacket( sendAllopt ) → {number}
Returns: number

Deprecated: This function is deprecated and will be removed.

Parameters

Name Type Attributes Default Value Description
sendAll boolean <optional>
false

Send all.

(static) sendIdentityPacket( ) → {number}
Returns: number

Deprecated: This function is deprecated and will be removed.

(static) setAbsoluteJointRotationInObjectFrame( index, rotation ) → {boolean}
Returns: false.

Sets the rotation of a joint relative to the avatar.

Warning: Not able to be used in the MyAvatar API.

Parameters

Name Type Description
index number

The index of the joint. Not used.

rotation Quat

The rotation of the joint relative to the avatar. Not used.

(static) setAbsoluteJointTranslationInObjectFrame( index, translation ) → {boolean}
Returns: false.

Sets the translation of a joint relative to the avatar.

Warning: Not able to be used in the MyAvatar API.

Parameters

Name Type Description
index number

The index of the joint. Not used.

translation Vec3

The translation of the joint relative to the avatar. Not used.

(static) setAnimGraphOverrideUrl( url )

Sets the animation graph to use in preference to the default animation graph.

See Custom Avatar Animations for information on animation graphs.

Parameters

Name Type Description
url string

The URL of the animation graph JSON file to use. Set to "" to clear an override.

(static) setAnimGraphUrl( url )

Sets the current animation graph (i.e., the avatar animation JSON) to use for avatar animations and makes it the default.

See Custom Avatar Animations for information on animation graphs.

Parameters

Name Type Description
url string

The URL of the animation graph JSON file to use.

(static) setAttachmentData( attachmentData )

Sets all models currently attached to your avatar. For example, if you retrieve attachment data using MyAvatar.getAttachmentData or Avatar.getAttachmentData, make changes to it, and then want to update your avatar's attachments per the changed data. You can also remove all attachments by using setting attachmentData to null.

Deprecated: This function is deprecated and will be removed. Use avatar entities instead.

Parameters

Name Type Description
attachmentData Array.<AttachmentData>

The attachment data defining the models to have attached to your avatar. Use null to remove all attachments.

Example

Remove a hat attachment if your avatar is wearing it.

var hatURL = "https://apidocs.vircadia.dev/models/cowboy-hat.fbx";
var attachments = MyAvatar.getAttachmentData();

for (var i = 0; i < attachments.length; i++) {
    if (attachments[i].modelURL === hatURL) {
        attachments.splice(i, 1);
        MyAvatar.setAttachmentData(attachments);
        break;
    }
 }

// Note: If using from the Avatar API, replace all occurrences of "MyAvatar" with "Avatar".
(static) setAttachmentsVariant( variant )

Sets all models currently attached to your avatar. For example, if you retrieve attachment data using MyAvatar.getAttachmentsVariant or Avatar.getAttachmentsVariant, make changes to it, and then want to update your avatar's attachments per the changed data.

Deprecated: This function is deprecated and will be removed. Use avatar entities instead.

Parameters

Name Type Description
variant Array.<AttachmentData>

The attachment data defining the models to have attached to your avatar.

(static) setAvatarEntityData( avatarEntityData )

Sets all avatar entities from an object.

Parameters

Name Type Description
avatarEntityData AvatarEntityMap

Details of the avatar entities.

(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

Name Type Description
scale number

The target scale for the avatar, range 0.0051000.0.

(static) setBlendshape( name, value )

Sets the value of a blend shape to animate your avatar's face. In order for other users to see the resulting animations on your avatar's face, set hasScriptedBlendshapes to true. When you are done using this API, set hasScriptedBlendshapes back to false when the animation is complete.

Parameters

Name Type Description
name string

The name of the blendshape, per the Avatar Standards.

value number

A value between 0.0 and 1.0.

Example

Open your avatar's mouth wide.

MyAvatar.hasScriptedBlendshapes = true;
MyAvatar.setBlendshape("JawOpen", 1.0);

// Note: If using from the Avatar API, replace "MyAvatar" with "Avatar".
(static) setCenterOfGravityModelEnabled( enabled )

Sets whether the avatar's hips are balanced over the feet or positioned under the head.

Parameters

Name Type Description
enabled boolean

true to balance the hips over the feet, false to position the hips under the head.

(static) setCharacterControllerEnabled( enabled )

Deprecated: This function is deprecated and will be removed. Use MyAvatar.setCollisionsEnabled instead.

Parameters

Name Type Description
enabled boolean

true to enable the avatar to collide with entities, false to disable.

(static) setCollisionsEnabled( enabled )

Sets whether the avatar should collide with entities.

Note: A false value won't disable collisions if the avatar is in a zone that disallows collisionless avatars. However, the false value will be set so that collisions are disabled as soon as the avatar moves to a position where collisionless avatars are allowed.

Parameters

Name Type Description
enabled boolean

true to enable the avatar to collide with entities, false to disable.

(static) setControlScheme( controlScheme )

Sets the control scheme to use.

Parameters

Name Type Description
controlScheme MyAvatar.LocomotionControlsMode

The control scheme to use.

(static) setDebugDrawAnimPoseName( poseName )

Sets the animation node to display when animation debug graphics are enabled with MyAvatar.setEnableDebugDrawAnimPose.

Parameters

Name Type Description
poseName string

The name of the animation node to display debug graphics for. Use "" to reset to default.

(static) setDominantHand( hand )

Sets the avatar's dominant hand.

Parameters

Name Type Description
hand string

The dominant hand: "left" for the left hand or "right" for the right hand. Any other value has no effect.

(static) setDriveGear1( shiftPoint )

Set the first 'shifting point' for acceleration step function.

Parameters

Name Type Description
shiftPoint number

Set the first shift point for analog movement acceleration step function, between [0.0, 1.0]. Must be less than or equal to Gear 2.

(static) setDriveGear2( shiftPoint )

Set the second 'shifting point' for acceleration step function.

Parameters

Name Type Description
shiftPoint number

Defines the second shift point for analog movement acceleration step function, between [0, 1]. Must be greater than or equal to Gear 1 and less than or equal to Gear 2.

(static) setDriveGear3( shiftPoint )

Set the third 'shifting point' for acceleration step function.

Parameters

Name Type Description
shiftPoint number

Defines the third shift point for analog movement acceleration step function, between [0, 1]. Must be greater than or equal to Gear 2 and less than or equal to Gear 4.

(static) setDriveGear4( shiftPoint )

Set the fourth 'shifting point' for acceleration step function.

Parameters

Name Type Description
shiftPoint number

Defines the fourth shift point for analog movement acceleration step function, between [0, 1]. Must be greater than Gear 3 and less than Gear 5.

(static) setDriveGear5( shiftPoint )

Set the fifth 'shifting point' for acceleration step function.

Parameters

Name Type Description
shiftPoint number

Defines the fifth shift point for analog movement acceleration step function, between [0, 1]. Must be greater than or equal to Gear 4.

(static) setEnableDebugDrawAnimPose( enabled )

Displays animation debug graphics. By default, the animation poses used for rendering are displayed. However, MyAvatar.setDebugDrawAnimPoseName can be used to set a specific animation node to display.

Parameters

Name Type Description
enabled boolean

true to show the debug graphics, false to hide.

(static) setEnableDebugDrawBaseOfSupport( enabled )

Displays the base of support area debug graphics if in HMD mode. If your head goes outside this area your avatar's hips are moved to counterbalance your avatar, and if your head moves too far then your avatar's position is moved (i.e., a step happens).

Parameters

Name Type Description
enabled boolean

true to show the debug graphics, false to hide.

(static) setEnableDebugDrawDefaultPose( enabled )

Displays default pose debug graphics.

Parameters

Name Type Description
enabled boolean

true to show the debug graphics, false to hide.

(static) setEnableDebugDrawDetailedCollision( enabled )

Displays detailed collision debug graphics.

Parameters

Name Type Description
enabled boolean

true to show the debug graphics, false to hide.

(static) setEnableDebugDrawHandControllers( enabled )

Displays controller hand target debug graphics.

Parameters

Name Type Description
enabled boolean

true to show the debug graphics, false to hide.

(static) setEnableDebugDrawIKChains( enabled )

Displays inverse kinematics chains debug graphics.

Parameters

Name Type Description
enabled boolean

true to show the debug graphics, false to hide.

(static) setEnableDebugDrawIKConstraints( enabled )

Displays inverse kinematics constraints debug graphics.

Parameters

Name Type Description
enabled boolean

true to show the debug graphics, false to hide.

(static) setEnableDebugDrawIKTargets( enabled )

Displays inverse kinematics targets debug graphics.

Parameters

Name Type Description
enabled boolean

true to show the debug graphics, false to hide.

(static) setEnableDebugDrawPosition( enabled )

Displays position debug graphics.

Parameters

Name Type Description
enabled boolean

true to show the debug graphics, false to hide.

(static) setEnableDebugDrawSensorToWorldMatrix( enable )

Displays sensor-to-world matrix debug graphics.

Parameters

Name Type Description
enable boolean

true to show the debug graphics, false to hide.

(static) setEnableInverseKinematics( enabled )

Sets whether inverse kinematics (IK) is enabled for your avatar.

Parameters

Name Type Description
enabled boolean

true to enable IK, false to disable.

(static) setEnableMeshVisible( enabled )

Sets whether your avatar mesh is visible to you.

Parameters

Name Type Description
enabled boolean

true to show your avatar mesh, false to hide.

Example

Make your avatar invisible for 10s.

MyAvatar.setEnableMeshVisible(false);
Script.setTimeout(function () {
    MyAvatar.setEnableMeshVisible(true);
}, 10000);
(static) setEyesLookAt( lookAtTarget )

Forces the avatar's eyes to look at a specified location. Once this method is called, API calls full control of the eyes for a limited time. If this method is not called for 2 seconds, the engine regains control of the eyes.

Parameters

Name Type Description
lookAtTarget Vec3

The target point in world coordinates.

(static) setFlyingDesktopPref( enabled )

Sets your preference for flying in desktop display mode. Note that your ability to fly also depends on whether the domain you're in allows you to fly.

Parameters

Name Type Description
enabled boolean

Set true if you want to enable flying in desktop display mode, otherwise set false.

(static) setFlyingEnabled( enabled )

Sets your preference for flying in your current desktop or HMD display mode. Note that your ability to fly also depends on whether the domain you're in allows you to fly.

Parameters

Name Type Description
enabled boolean

Set true if you want to enable flying in your current desktop or HMD display mode, otherwise set false.

(static) setFlyingHMDPref( enabled )

Sets your preference for flying in HMD display mode. Note that your ability to fly also depends on whether the domain you're in allows you to fly.

Parameters

Name Type Description
enabled boolean

Set true if you want to enable flying in HMD display mode, otherwise set false.

(static) setForceFaceTrackerConnected( connected )

Enables blend shapes set using Avatar.setBlendshape or MyAvatar.setBlendshape to be transmitted to other users so that they can see the animation of your avatar's face.

Deprecated: This method is deprecated and will be removed. Use the Avatar.hasScriptedBlendshapes or MyAvatar.hasScriptedBlendshapes property instead.

Parameters

Name Type Description
connected boolean

true to enable blend shape changes to be transmitted to other users, false to disable.

(static) setGravity( gravity )

Sets the amount of gravity applied to the avatar in the y-axis direction. (Negative values are downward.)

Parameters

Name Type Description
gravity number

The amount of gravity to be applied to the avatar, in m/s2.

(static) setHandRelativeMovement( enabled )

Set your preference for hand-relative movement.

Parameters

Name Type Description
enabled number

Set true if you want to enable hand-relative movement, otherwise set to false.

(static) setHandState( state )

Sets the pointing state of the hands to control where the laser emanates from. If the right index finger is pointing, the laser emanates from the tip of that finger, otherwise it emanates from the palm.

Parameters

Name Type Description
state HandState

The pointing state of the hand.

(static) setHeadLookAt( lookAtTarget )

Turns the avatar's head until it faces the target point within a +90/-90 degree range. Once this method is called, API calls have full control of the head for a limited time. If this method is not called for 2 seconds, the engine regains control of the head.

Parameters

Name Type Description
lookAtTarget Vec3

The target point in world coordinates.

(static) setHmdAvatarAlignmentType( type )

Sets the HMD alignment relative to your avatar.

Parameters

Name Type Description
type string

"head" to align your head and your avatar's head, "eyes" to align your eyes and your avatar's eyes.

(static) setHMDLeanRecenterEnabled( enabled )

Sets whether the avatar's position updates to recenter the avatar under the head. In room-scale VR, recentering causes your avatar to follow your HMD as you walk around the room. Disabling recentering is useful if you want to pin the avatar to a fixed position.

Parameters

Name Type Description
enabled boolean

true to recenter the avatar under the head as it moves, false to disable recentering.

(static) setHoverWhenUnsupported( hover )

Sets whether your avatar hovers when its feet are not on the ground.

Parameters

Name Type Description
hover boolean

true if your avatar hovers when its feet are not on the ground, false if it falls.

(static) setJointData( index, 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

Name Type Description
index number

The index of the joint.

rotation Quat

The rotation of the joint relative to its parent.

translation Vec3

The translation of the joint relative to its parent, in model coordinates.

Example

Set your avatar to it's default T-pose for a while.
Avatar in T-pose

// Set all joint translations and rotations to defaults.
var i, length, rotation, translation;
for (i = 0, length = MyAvatar.getJointNames().length; i < length; i++) {
    rotation = MyAvatar.getDefaultJointRotation(i);
    translation = MyAvatar.getDefaultJointTranslation(i);
    MyAvatar.setJointData(i, rotation, translation);
}

// Restore your avatar's motion after 5s.
Script.setTimeout(function () {
    MyAvatar.clearJointsData();
}, 5000);

// Note: If using from the Avatar API, replace all occurrences of "MyAvatar" with "Avatar".
(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

Name Type Description
name string

The name of the joint.

rotation Quat

The rotation of the joint relative to its parent.

translation Vec3

The translation of the joint relative to its parent, in model coordinates.

(static) setJointRotation( index, 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

Name Type Description
index number

The index of the joint.

rotation Quat

The rotation of the joint relative to its parent.

(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

Name Type Description
name string

The name of the joint.

rotation Quat

The rotation of the joint relative to its parent.

Example

Set your avatar to its default T-pose then rotate its right arm.
Avatar in T-pose with arm rotated

// Set all joint translations and rotations to defaults.
var i, length, rotation, translation;
for (i = 0, length = MyAvatar.getJointNames().length; i < length; i++) {
    rotation = MyAvatar.getDefaultJointRotation(i);
    translation = MyAvatar.getDefaultJointTranslation(i);
    MyAvatar.setJointData(i, rotation, translation);
}

// Rotate the right arm.
var newArmRotation = { x: 0.47, y: 0.22, z: -0.02, w: 0.87 };
MyAvatar.setJointRotation("RightArm", newArmRotation);

// Restore your avatar's motion after 5s.
Script.setTimeout(function () {
    MyAvatar.clearJointsData();
}, 5000);

// Note: If using from the Avatar API, replace all occurrences of "MyAvatar" with "Avatar".
(static) setJointRotations( jointRotations )

Sets the rotations of all joints in the current avatar. Each joint's rotation is relative to its parent joint.

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

Name Type Description
jointRotations Array.<Quat>

The rotations for all joints in the avatar. The values are in the same order as the array returned by MyAvatar.getJointNames, or Avatar.getJointNames if using the Avatar API.

Example

Set your avatar to its default T-pose then rotate its right arm.
Avatar in T-pose

// Set all joint translations and rotations to defaults.
var i, length, rotation, translation;
for (i = 0, length = MyAvatar.getJointNames().length; i < length; i++) {
    rotation = MyAvatar.getDefaultJointRotation(i);
    translation = MyAvatar.getDefaultJointTranslation(i);
    MyAvatar.setJointData(i, rotation, translation);
}

// Get all join rotations.
var jointRotations = MyAvatar.getJointRotations();

// Update the rotation of the right arm in the array.
jointRotations[MyAvatar.getJointIndex("RightArm")] = { x: 0.47, y: 0.22, z: -0.02, w: 0.87 };

// Update all joint rotations.
MyAvatar.setJointRotations(jointRotations);

// Restore your avatar's motion after 5s.
Script.setTimeout(function () {
    MyAvatar.clearJointsData();
}, 5000);

// Note: If using from the Avatar API, replace all occurrences of "MyAvatar" with "Avatar".
(static) setJointTranslation( index, 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

Name Type Description
index number

The index of the joint.

translation Vec3

The translation of the joint relative to its parent, in model coordinates.

(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

Name Type Description
name string

The name of the joint.

translation Vec3

The translation of the joint relative to its parent, in model coordinates.

Example

Stretch your avatar's neck. Depending on the avatar you are using, you will either see a gap between the head and body or you will see the neck stretched.
Avatar with neck stretched

// Stretch your avatar's neck.
MyAvatar.setJointTranslation("Neck", Vec3.multiply(2, MyAvatar.getJointTranslation("Neck")));

// Restore your avatar's neck after 5s.
Script.setTimeout(function () {
    MyAvatar.clearJointData("Neck");
}, 5000);

// Note: If using from the Avatar API, replace all occurrences of "MyAvatar" with "Avatar".
(static) setJointTranslations( translations )

Sets the translations of all joints in the current avatar. Each joint's translation is relative to its parent joint, 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

Name Type Description
translations Array.<Vec3>

The translations for all joints in the avatar, in model coordinates. The values are in the same order as the array returned by MyAvatar.getJointNames, or Avatar.getJointNames if using the Avatar API.

(static) setModelScale( scale )

Deprecated: This function is deprecated and will be removed.

Parameters

Name Type Description
scale number

The scale.

(static) setModelURLFinished( success )

Deprecated: This function is deprecated and will be removed.

Parameters

Name Type Description
success boolean
(static) setOrientationVar( newOrientationVar )

Gets the avatar orientation. Suitable for use in QML.

Parameters

Name Type Description
newOrientationVar object

The avatar's orientation.

(static) setOtherAvatarsCollisionsEnabled( enabled )

Sets whether the avatar should collide with other avatars.

Parameters

Name Type Description
enabled boolean

true to enable the avatar to collide with other avatars, false to disable.

(static) setParentID( parentID )

Sets the ID of the entity or avatar that the avatar is parented to.

Parameters

Name Type Description
parentID Uuid

The ID of the entity or avatar that the avatar should be parented to. Set to Uuid.NULL to unparent.

(static) setParentJointIndex( parentJointIndex )

Sets the joint of the entity or avatar that the avatar is parented to.

Parameters

Name Type Description
parentJointIndex number

The joint of the entity or avatar that the avatar should be parented to. Use 65535 or -1 to parent to the entity or avatar's position and orientation rather than a joint.

(static) setPointAt( pointAtTarget ) → {boolean}
Returns: true if the target point was set, false if it wasn't.

Sets the point-at target for the "point" reaction that may be started with MyAvatar.beginReaction. The point-at target is set only if it is in front of the avatar.

Note: The "point" reaction should be started before calling this method.

Parameters

Name Type Description
pointAtTarget Vec3

The target to point at, in world coordinates.

(static) setRawJointData( data )

Sets joint translations and rotations from raw joint data.

Deprecated: This function is deprecated and will be removed.

Parameters

Name Type Description
data Array.<JointData>

The raw joint data.

(static) setSessionUUID( sessionUUID )

Deprecated: This function is deprecated and will be removed.

Parameters

Name Type Description
sessionUUID Uuid

Session UUID.

(static) setSkeletonModelURL( url )

Sets the avatar's skeleton model.

Parameters

Name Type Description
url string

The avatar's FST file.

(static) setSkeletonOffset( offset )

Sets the offset applied to the current avatar. The offset adjusts the position that the avatar is rendered. For example, with an offset of { x: 0, y: 0.1, z: 0 }, your avatar will appear to be raised off the ground slightly.

Parameters

Name Type Description
offset Vec3

The skeleton offset to set.

Example

Raise your avatar off the ground a little.

// Raise your avatar off the ground a little.
MyAvatar.setSkeletonOffset({ x: 0, y: 0.1: z: 0 });

// Restore its offset after 5s.
Script.setTimeout(function () {
    MyAvatar.setSkeletonOffset(Vec3.ZERO);
}, 5000);
(static) setSnapTurn( on )

Sets whether you do snap turns or smooth turns in HMD mode.

Parameters

Name Type Description
on boolean

true to do snap turns in HMD mode; false to do smooth turns in HMD mode.

(static) setStrafeEnabled( enabled )

Sets whether strafing is enabled.

Parameters

Name Type Description
enabled boolean

true if strafing is enabled, false if it isn't.

(static) setThrust( thrust )

Sets the thrust to be applied to your avatar for a short while.

Deprecated: This function is deprecated and will be removed. Use MyAvatar.motorVelocity and related properties instead.

Parameters

Name Type Description
thrust Vec3

The thrust direction and magnitude.

(static) setToggleHips( enabled )

Deprecated: This function is deprecated and will be removed.

Parameters

Name Type Description
enabled boolean

Enabled.

(static) targetScaleChanged( targetScale )
Returns: Signal

Triggered when the avatar's target scale is changed. The target scale is the desired scale of the avatar without any restrictions on permissible scale values imposed by the domain.

Parameters

Name Type Description
targetScale number

The avatar's target scale.

(static) triggerHorizontalRecenter( )

Recenter the avatar in the horizontal direction, if MyAvatar.hmdLeanRecenterEnabled is false.

(static) triggerReaction( reactionName ) → {boolean}
Returns: true if the reaction was played, false if the reaction is not supported.

Plays a reaction on the avatar. Once the reaction is complete it will stop playing.

Only reaction names returned by MyAvatar.getTriggerReactions are available.

Parameters

Name Type Description
reactionName string

The reaction to trigger.

(static) triggerRotationRecenter( )

Recenter the avatar's rotation, if MyAvatar.hmdLeanRecenterEnabled is false.

(static) triggerVerticalRecenter( )

Recenter the avatar in the vertical direction, if MyAvatar.hmdLeanRecenterEnabled is false.

(static) updateAvatarEntity( entityID, entityData )

Deprecated: This function is deprecated and will be removed.

Parameters

Name Type Description
entityID Uuid

The entity ID.

entityData ArrayBuffer

Entity data.

(static) updateMotionBehaviorFromMenu( )

Updates avatar motion behavior from the Developer > Avatar > Enable Default Motor Control and Enable Scripted Motor Control menu items.

(static) useFlow( isActive, isCollidable, physicsConfigopt, collisionsConfigopt )

Enables and disables flow simulation of physics on the avatar's hair, clothes, and body parts. See Add Flow to Your Avatar for more information.

Parameters

Name Type Attributes Description
isActive boolean

true if flow simulation is enabled on the joint, false if it isn't.

isCollidable boolean

true to enable collisions in the flow simulation, false to disable.

physicsConfig Object.<JointName, MyAvatar.FlowPhysicsOptions> <optional>

Physics configurations for particular entity and avatar joints.

collisionsConfig Object.<JointName, MyAvatar.FlowCollisionsOptions> <optional>

Collision configurations for particular entity and avatar joints.

(static) useFullAvatarURL( fullAvatarURL, modelNameopt )

Changes the user's avatar and associated descriptive name.

Parameters

Name Type Attributes Default Value Description
fullAvatarURL string

The URL of the avatar's .fst file.

modelName string <optional>
""

Descriptive name of the avatar.

(static) worldToJointDirection( direction, jointIndexopt ) → {Vec3}
Returns: The direction in the joint's coordinate system, or avatar coordinate system if no joint is specified.

Transforms a direction in world coordinates to a direction in a joint's coordinates, or avatar coordinates if no joint is specified.

Parameters

Name Type Attributes Default Value Description
direction Vec3

The direction in world coordinates.

jointIndex number <optional>
-1

The index of the joint.

(static) worldToJointPoint( position, jointIndexopt ) → {Vec3}
Returns: The position in the joint's coordinate system, or avatar coordinate system if no joint is specified.

Transforms a position in world coordinates to a position in a joint's coordinates, or avatar coordinates if no joint is specified.

Parameters

Name Type Attributes Default Value Description
position Vec3

The position in world coordinates.

jointIndex number <optional>
-1

The index of the joint.

(static) worldToJointRotation( rotation, jointIndexopt ) → {Quat}
Returns: The rotation in the joint's coordinate system, or avatar coordinate system if no joint is specified.

Transforms a rotation in world coordinates to a rotation in a joint's coordinates, or avatar coordinates if no joint is specified.

Parameters

Name Type Attributes Default Value Description
rotation Quat

The rotation in world coordinates.

jointIndex number <optional>
-1

The index of the joint.

Signal Details

analogPlusSprintSpeedChanged( speed )
Returns: Signal

Triggered when the sprint (run) speed set for the "AnalogPlus" control scheme changes.

Parameters

Name Type Description
speed number

The new sprint speed set for the "AnalogPlus" control scheme.

analogPlusWalkSpeedChanged( speed )
Returns: Signal

Triggered when the walk speed set for the "AnalogPlus" control scheme changes.

Parameters

Name Type Description
speed number

The new walk speed set for the "AnalogPlus" control scheme.

animGraphUrlChanged( url )
Returns: Signal

Triggered when the avatar's animation graph being used changes.

Parameters

Name Type Description
url string

The URL of the new animation graph JSON file.

Example

Report when the current avatar animation JSON being used changes.

MyAvatar.animGraphUrlChanged.connect(function (url) {
    print("Avatar animation JSON changed to: " + url);
});
attachmentsChanged( )
Returns: Signal

Triggered when the a model is attached to or detached from one of the avatar's joints using one of attach, detachOne, detachAll, or setAttachmentData.

Deprecated: This signal is deprecated and will be removed. Use avatar entities instead.

audioListenerModeChanged( )
Returns: Signal

Triggered when the audioListenerMode property value changes.

collisionsEnabledChanged( enabled )
Returns: Signal

Triggered when collisions with the environment are enabled or disabled.

Parameters

Name Type Description
enabled boolean

true if collisions with the environment are enabled, false if they're not.

collisionWithEntity( collision )
Returns: Signal

Triggered when the avatar collides with an entity.

Parameters

Name Type Description
collision Collision

Details of the collision.

Example

Report each time your avatar collides with an entity.

MyAvatar.collisionWithEntity.connect(function (collision) {
    print("Your avatar collided with an entity.");
});
disableHandTouchForIDChanged( entityID, disabled )
Returns: Signal

Triggered when the hand touch is enabled or disabled on a specific entity.

The hand touch effect makes the avatar's fingers adapt to the shape of any object grabbed, creating the effect that it is really touching that object.

Parameters

Name Type Description
entityID Uuid

The entity that the hand touch effect has been enabled or disabled for.

disabled boolean

true if the hand touch effect is disabled for the entity, false if it isn't disabled.

displayNameChanged( )
Returns: Signal

Triggered when the avatar's displayName property value changes.

Example

Report when your avatar display name changes.

MyAvatar.displayNameChanged.connect(function () {
    print("Avatar display name changed to: " + MyAvatar.displayName);
});

// Note: If using from the Avatar API, replace "MyAvatar" with "Avatar".
dominantHandChanged( hand )
Returns: Signal

Triggered when the avatar's dominant hand changes.

Parameters

Name Type Description
hand string

The dominant hand: "left" for the left hand, "right" for the right hand.

energyChanged( energy )
Returns: Signal

Deprecated: This signal is deprecated and will be removed.

Parameters

Name Type Description
energy number

Avatar energy.

hmdAvatarAlignmentTypeChanged( type )
Returns: Signal

Triggered when the HMD alignment for your avatar changes.

Parameters

Name Type Description
type string

"head" if aligning your head and your avatar's head, "eyes" if aligning your eyes and your avatar's eyes.

lookAtSnappingChanged( enabled )
Returns: Signal

Triggered when the avatar's lookAtSnappingEnabled property value changes.

Parameters

Name Type Description
enabled boolean

true if look-at snapping is enabled, false if not.

Example

Report when your look-at snapping setting changes.

MyAvatar.lookAtSnappingChanged.connect(function () {
    print("Avatar look-at snapping changed to: " + MyAvatar.lookAtSnappingEnabled);
});

// Note: If using from the Avatar API, replace "MyAvatar" with "Avatar".
newCollisionSoundURL( url )
Returns: Signal

Triggered when the collisionSoundURL property value changes.

Parameters

Name Type Description
url string

The URL of the new collision sound.

onLoadComplete( )
Returns: Signal

Triggered when the avatar's model finishes loading.

onLoadFailed( )
Returns: Signal

Triggered when the avatar's model has failed to load.

otherAvatarsCollisionsEnabledChanged( enabled )
Returns: Signal

Triggered when collisions with other avatars are enabled or disabled.

Parameters

Name Type Description
enabled boolean

true if collisions with other avatars are enabled, false if they're not.

positionGoneTo( )
Returns: Signal

Triggered when the avatar has been moved to a new position by one of the MyAvatar "goTo" functions.

scaleChanged( )
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.

sensorToWorldScaleChanged( scale )
Returns: Signal

Triggered when the avatar's sensorToWorldScale property value changes.

Parameters

Name Type Description
scale number

The scale that transforms dimensions in the user's real world to the avatar's size in the virtual world.

sessionDisplayNameChanged( )
Returns: Signal

Triggered when the avatar's sessionDisplayName property value changes.

Example

Report when your avatar's session display name changes.

MyAvatar.sessionDisplayNameChanged.connect(function () {
    print("Avatar session display name changed to: " + MyAvatar.sessionDisplayName);
});

// Note: If using from the Avatar API, replace "MyAvatar" with "Avatar".
sessionUUIDChanged( )
Returns: Signal

Triggered when the avatar's sessionUUID property value changes.

Example

Report when your avatar's session UUID changes.

MyAvatar.sessionUUIDChanged.connect(function () {
    print("Avatar session UUID changed to: " + MyAvatar.sessionUUID);
});

// Note: If using from the Avatar API, replace "MyAvatar" with "Avatar".
shouldDisableHandTouchChanged( disabled )
Returns: Signal

Triggered when the hand touch effect is enabled or disabled for the avatar.

The hand touch effect makes the avatar's fingers adapt to the shape of any object grabbed, creating the effect that it is really touching that object.

Parameters

Name Type Description
disabled boolean

true if the hand touch effect is disabled for the avatar, false if it isn't disabled.

skeletonChanged( )
Returns: Signal

Triggered when the avatar's model (i.e., skeletonModelURL property value) is changed.

Synonym of skeletonModelURLChanged.

skeletonModelURLChanged( )
Returns: Signal

Triggered when the avatar's model (i.e., skeletonModelURL property value) changes.

Example

Report when your avatar's skeleton model changes.

MyAvatar.skeletonModelURLChanged.connect(function () {
    print("Skeleton model changed to: " + MyAvatar.skeletonModelURL);
});

// Note: If using from the Avatar API, replace "MyAvatar" with "Avatar".
sprintSpeedChanged( speed )
Returns: Signal

Triggered when the sprint (run) speed set for the current control scheme (see getControlScheme) changes.

Parameters

Name Type Description
speed number

The new sprint speed set for the current control scheme.

transformChanged( )
Returns: Signal

Deprecated: This signal is deprecated and will be removed.

walkBackwardSpeedChanged( speed )
Returns: Signal

Triggered when the walk backward speed set for the current control scheme (see getControlScheme) changes.

Parameters

Name Type Description
speed number

The new walk backward speed set for the current control scheme.

wentActive( )
Returns: Signal

Triggered when your avatar changes from being away to being active.

wentAway( )
Returns: Signal

Triggered when your avatar changes from being active to being away.

Example

Report when your avatar goes away.

MyAvatar.wentAway.connect(function () {
    print("My avatar went away");
});
// In desktop mode, pres the Esc key to go away.