Player Avatar Container

PlayerAvatarContainer Documentation

The PlayerAvatarContainer component is used to manage the player's avatar in a Metaverse scene. It is responsible for loading and spawning the avatar, as well as playing animations on the avatar.



Public Methods

  • void ClearLoadedAvatar(): Destroys the currently loaded avatar.

  • void LoadAvatar(): Loads and spawns the player's avatar.

  • void EquipAvatarUrl(): If an AvatarUrl is specified, will equip that specific avatar.

  • AnimationClipPlayable PlayAnimation(AnimationClip clip, float? duration = null, AvatarMask mask = null, float fadeInTime = 0, float fadeOutTime = 0): Plays an animation on the avatar.

  • void StopAllAnimations(float fadeOutTime = 0): Stops all currently active animations on the avatar.

  • bool IsPlayingAnimation(AnimationClipPlayable handle): Returns true if the specified animation is currently playing.

  • void StopAnimation(AnimationClipPlayable handle, float fadeOutTime = 0): Stops the specified animation.

Public Properties

  • AvatarContainerEvents Events (read only): Events that are invoked when the avatar state changes.

  • Animator OwnAnimator (read only): The Animator component attached to the same GameObject as this component.

  • Animator Avatar (read only): The Animator component of the spawned avatar.

  • string AvatarUrl: The URL of the avatar to load.

Inspector Fields

  • bool avatarLoading: Whether or not to automatically load the avatar.

  • string avatarUrl: The URL of the avatar to load.

  • AvatarType avatarUrlType: The type of avatar URL.

  • AvatarContainerEvents events: Events that are invoked when the avatar state changes.

  • bool autoDetectAnimatorChanges: Whether or not to automatically detect changes to the animator controller.


  • Execution Order: This class inherits from NetworkObjectBehaviour, which uses the ExecutionOrder.Finalize execution order.


  1. To use PlayerAvatarContainer, start by adding the component to a GameObject in your scene. This GameObject will typically be the player's GameObject.

  2. If you want to use a custom avatar, specify the URL of the avatar in the avatarUrl field.

  3. You can then use the public methods to control the avatar, such as playing animations.

  4. You can also listen to the events in the events property to trigger other behaviors when the avatar state changes.


You can use the PlayerAvatarContainer component to play an animation on the player's avatar when a button is clicked. To do this:

  1. Add the PlayerAvatarContainer component to the player's GameObject.

  2. Create a Button in your UI.

  3. Add a Unity Event to the Button's onClick event.

  4. In the Unity Event, select the player's GameObject and then select the PlayAnimation method.

  5. In the PlayAnimation method call, pass in the animation clip that you want to play.

This will play the animation on the player's avatar when the Button is clicked.

Last updated