Define LocalPlayer interface.

interface ILocalPlayer {
    avatar?: IAvatar;
    canFly: undefined | boolean;
    canHardLanding: boolean;
    canJump: boolean;
    canMove: boolean;
    canRun: boolean;
    collision: null | CollisionComponent;
    fallingGravityMultiplier: number;
    flySpeedMultiplier: number;
    gravityMultiplier: number;
    isDisposed: boolean;
    isVisible: boolean;
    isVisibleRemotely: boolean;
    jumpMultiplier: number;
    nameTag?: INameTag;
    network?: INetwork;
    profile?: IPlayerProfile;
    respawnPosition: null | Vec3;
    runSpeedMultiplier: number;
    spawnCount: number;
    velocity?: Vec3;
    walkSpeedMultiplier: number;
    changeAvatar(asset: Asset): void;
    fire<T>(event: T, ...args?: any[]): EventHandler;
    jump(): void;
    off<T>(event: T, listener: ILocalPlayerEvents[T]): EventHandler;
    on<T>(event: T, listener: ILocalPlayerEvents[T]): EventHandle;
    playAnimation(stateName: string, options?: {
        asset?: Asset;
        lock: boolean;
        loop: boolean;
    }): Promise<null | Asset>;
    resetToViverseAvatar(): void;
    respawn(timeout?: number): void;
    scaleAvatar(scale: number, options?: {
        sync?: boolean;
    }): void;
    stopAnimation(): void;
    teleport(destination: Vec3, rotationY?: number): void;
    turnToward(x: number | Vec2, y?: number): void;
}

Hierarchy (view full)

Properties

avatar?: IAvatar

Get the player's avatar information.

canFly: undefined | boolean

Whenther the player can fly.

canHardLanding: boolean

Whenther the player can hard land.

canJump: boolean

Whether the player can jump.

canMove: boolean

Whether the player can move.

canRun: boolean

Whether the player can run.

collision: null | CollisionComponent

Player's collision, default collision type is capsule.

fallingGravityMultiplier: number

Fall speed multiplier
Use this parameter to enhance the feeling of gravity effect when falling.
For example, when the character starts to fall after jumping, gravity will increase with this multiplier, causing the character to reach the ground faster.

flySpeedMultiplier: number

Flight speed multiplier.

gravityMultiplier: number

The gravity multiplier that affects both ascent and descent.

isDisposed: boolean

Get the status that whether the Player has disconnected from the server.

isVisible: boolean

Whether the player is visible on the local client.

isVisibleRemotely: boolean

Whether the character can be seen by remote players.

jumpMultiplier: number

Jump height multiplier.

nameTag?: INameTag

Get the player's name tag.

network?: INetwork

Get the player's server connection information.

profile?: IPlayerProfile

Get the player's profile information.

respawnPosition: null | Vec3

Player's respawn point, default is null.
When executing respawn(), first using respawnPosition as the respawn location.
If respawnPosition is null, the respawn location will be determined by the original VIVERSE CREATE mechanism (checkpoint, spawn-point tag).

runSpeedMultiplier: number

Running speed multiplier.

spawnCount: number

Get the player's respawn count.

velocity?: Vec3

Get the character's current speed.

walkSpeedMultiplier: number

Walking speed multiplier.

Methods

  • Change the avatar model.

    Parameters

    • asset: Asset

      Avatar model asset.

    Returns void

  • Send a specific event.

    Type Parameters

    Parameters

    • event: T

      Event name

    • Optional Rest...args: any[]

      Event parameters

    Returns EventHandler

  • Make the character jump in place. If successful, it will trigger the jump:start event.
    In some cases, the character may not be able to jump, such as when the character is falling, is already in a jumping state, or is affected by external forces.

    Returns void

  • Unsubscribe from a specific event.

    Type Parameters

    Parameters

    Returns EventHandler

  • Subscribe to a specific event.

    Type Parameters

    Parameters

    Returns EventHandle

  • Play a custom animation.

    Parameters

    • stateName: string

      The stateName of animation.

    • Optionaloptions: {
          asset?: Asset;
          lock: boolean;
          loop: boolean;
      }

      Optional parameters.

      • Optionalasset?: Asset

        Send the vrma file.

      • lock: boolean

        Lock the animation. Default is false.

      • loop: boolean

        Loop the animation. Default is false.

    Returns Promise<null | Asset>

    • Return the animation asset.
  • Reset the avatar model to the default VIVERSE avatar model.

    Returns void

  • Send the character back to the respawn point (respawnPosition), with the respawned event triggered.
    If respawnPosition is null, the respawn location will be determined by the original VIVERSE CREATE mechanism (checkpoint, spawn-point tag).

    Parameters

    • Optionaltimeout: number

      Delay the respawn time (in milliseconds).

    Returns void

  • Planned

    Scale the avatar model with the specified scale ratio.

    Parameters

    • scale: number

      Scale ratio

    • Optionaloptions: {
          sync?: boolean;
      }

      Optional parameters

      • Optionalsync?: boolean

        Whether to sync scaling to other players over the network. Default is true.

    Returns void

  • Stop all currently playing animations.

    Returns void

  • Teleport the character to the target location.

    Parameters

    • destination: Vec3

      Target location

    • OptionalrotationY: number

      Y-axis rotation angle

    Returns void

  • Make the character face the target’s position on the horizontal plane.

    Parameters

    • x: number | Vec2

      X-coordinate of the target’s position on the horizontal plane, or the target's horizontal position.

    • Optionaly: number

      Y-coordinate of the target’s position on the horizontal plane.

    Returns void