Skip to main content

Avatar

A reference to an avatar in the world. This object is provided in events and returned from methods like getAvatar(id) etc.

import React, { useEffect } from "react";
import { useWorld } from "hyperfy";

export default function App() {
const world = useWorld();

useEffect(() => {
return world.on("join", (avatar) => {
console.log(avatar.name);
});
}, []);

return <app />;
}

Props

PropTypeDescription
uidStringThe UID of the avatar
nameStringThe name of the avatar
addressStringThe wallet address of the avatar (if connected)

Ref

FieldDescription
teleport(placeLabel)Teleports the avatar to a Place with that label. If multiple places with the same label exist it will pick one at random.
getPosition(vec3)Gets the world position of the avatar and applies it to the provided Vector3
getBonePosition(boneName, vec3)Gets the world position of a specific bone and applies it to the provided Vector3
getBoneRotation(boneName, eul)Gets the world rotation of a specific bone and applies it to the provided Euler
getRay(hand)Returns a ray for either a specific hand (leftHand or rightHand) otherwise uses eyes as the origin.

ray

PropTypeDescription
originVector3The origin position of the ray
directionVector3a vector pointing in the direction the ray will be cast