IAvatar

Actor Service

Interface

Properties

airControl

How much control the player has over the character while in the air. A value of 0 means no control, 1 means full control.

fallingGravityMultiplier

Multiplier on top of the default gravity settings for the space just for the local avatar while falling. This stacks on top of gravityMultiplier. This is useful for making the avatar fall faster than they jump.

gravityMultiplier

Multiplier on top of the default gravity settings for the space just for the local avatar.

groundFriction

Contribution of how much ground friction to apply to the character. A higher value will give the avatar more grip resulting in higher acceleration. This does not affect the avatar's maximum movement speed. Values should be between 0 and 1.

jumpHeight

The height in meters that the avatar can jump

maxJumpCount

Maximum number of times that the avatar can jump in a row before touching the ground.

nametagBarValue

Optional nametag bar value shown in the nametag above the avatar's head.

nametagBarVisible

Whether the nametag bar is visible.

nametagSubtext

An optional subtext shown in the nametag above the avatar's head.

nametagVisible

Whether the nametag should be visible to other users.

position

The current position of the avatar's visual representation in the scene. This is the position of the avatar at the feet.

ragdollVelocity

The current velocity of the avatar's ragdoll body.

rotation

The orientation of the avatar's visual representation in the scene. Currently this is always locked to Y-up.

runSpeed

The running speed of the avatar in meters per second.

useVariableHeightJump

When enabled, jump is higher depending on how long jump button is held down. Currently variable jump height may result in a slightly higher jumpHeight

velocity

The current velocity of the avatar

visibleRemotely

Whether the avatar is visible in the scene to other remote users.

walkSpeed

The walking speed of the avatar in meters per second.

Methods

AddForce(Vector3)

Add a force to the avatar's rigidbody. This is different from ragdoll force, and just affects the avatar's character controller.

AddRagdollForce(Vector3, bool)

Add a force to the avatar's ragdoll body. This will only work if ragdoll physics are enabled for the space and avatar. See SetRagdollPhysicsActive.

ClearAttachmentSlot(Slot)

Clear avatar attachments currently equipped in a specific slot. This does not affect the user's profile avatar, just the attachments that were equipped in this session.

ClearAttachments()

Clear all avatar attachments that were equipped with EquipAttachment. This does not affect the user's profile avatar, just the attachments that were equipped in this session.

ClearAttachmentsByTag(string)

Clear avatar attachments currently equipped that have this tag set. This does not affect the user's profile avatar, just the attachments that were equipped in this session.

EquipAttachment(AssetType, string, bool, bool, string)

Equip an attachment to the avatar (Defined by the SpatialAvatarAttachment component)

IsAttachmentEquipped(string)

Is the attachment currently equipped?

Jump()

If possible, make the avatar jump. Sometimes the avatar is not able to jump, such as when they are not grounded if maxJumpCount is exceeded.

Move(Vector2, bool)

Move the avatar in the direction of the input vector. This function should only be used for player input. For AI movement, use SetDestination instead.

PlayEmote(AssetType, string, bool, bool)

Play an emote on the avatar (Defined by the SpatialAvatarAnimation component)

ResetAvatarBody()

Reset the avatar body asset to what the user has set in their profile if it was overridden with SetAvatarBody.

Respawn()

Respawn the avatar at a valid entrance point or seat in the space. If avatar is currently ragdolling, this will also reset the ragdoll state.

SetAvatarBody(AssetType, string)

Set the avatar body to an avatar defined by SpatialAvatar component. This temporarily overrides the user's profile avatar just for this session, and can be reverted with

ResetAvatarBody
SetDestination(Vector3, bool)

Order the avatar to move to a destination using a navmesh if available. If there is no navmesh, the avatar will move directly to the destination in a straight line.

SetPositionRotation(Vector3, Quaternion)

Teleport the avatar to a new position and rotation. This is faster than setting the position and rotation separately.

SetRagdollPhysicsActive(bool, Vector3)

Set ragdoll physics active state. This can only be done if ragdoll physics feature is enabled for the space.

Sit(Transform)

Teleports the avatar to the target transform and makes the avatar sit on the target.

Stand()

If currently sitting, this will make the avatar stand up.

StopEmote()

Stop the current emote on the avatar that was started with PlayEmote

Events

onAttachmentEquippedChanged

Event that is triggered when an avatar attachment is equipped or unequipped. Note that the game object for the attachment may not exist yet when this event is triggered. This is because the attachment is loaded asynchronously (its asset bundle may need to be downloaded first).

Inherited Members

Equals(IAvatar)
Equals(IReadOnlyAvatar)
GetAvatarBoneTransform(HumanBodyBones)

Get the transform of a bone in the avatar's body.

bodyMaterials

Returns a collection of all materials used on the avatar's body. This can be used to change the appearance of the avatar.

displayName

The display name shown in the nametag above the avatar's head.

isBodyLoaded

Whether the avatar body is fully loaded. When users join a space, their avatar body is not immediately loaded. This property will be false until the avatar body is loaded. It's also possible for users to switch their avatars on the fly, so this property may change at any time. Use the onAvatarLoadComplete and onAvatarBeforeUnload event to be notified when the avatar body is loaded or unloaded.

isDisposed

Returns true when the component or its parent space object has been destroyed.

isGrounded

Whether the avatar is currently grounded (the feet are touching the ground)

onAvatarBeforeUnload

Event that triggers when the avatar is about to be unloaded. If the avatar is owned by an actor, this may be because the actor has changed their avatar, or because the actor is leaving or disconnecting. This can be used to "deconstruct" anything that was created in the onAvatarLoadComplete event. isBodyLoaded will be set to false after this event is triggered.

onAvatarLoadComplete

Event that triggers when the avatar has finished loading. isBodyLoaded will be set to true before this event is triggered.

onColliderHit

Event that is triggered when the avatar's collider hits another collider.

onEmote

Event that is triggered when an emote avatar animation is started. Note that this doesn't trigger immediately when PlayEmote is called, but when the animation is loaded (asynchronously) and started.

onIsGroundedChanged

Event that is triggered when the avatar's grounded state changes (isGrounded)

onJump

Event that is triggered when the avatar starts to jump

onLanded

Event that is triggered when the avatar lands on the ground

onRespawned

Event that triggers when the avatar is respawned. Respawn can happen when:

  • A user's avatar enters a space and is spawned for the first time
  • An avatar is explicitly respawned with Respawn
  • An avatar goes out of bounds

For avatars created explicitly through SpawnAvatar this event will not trigger

ragdollPhysicsActive

Is ragdoll physics currently active for the avatar?

spaceObject

The space object the component is attached to.

spaceObjectID

The id of the spaceObject the component is attached to.

visibleLocally

Whether the avatar is visible in the scene.