lookAtCursor
import { Vrm } from "@hmcs/sdk";
vrm.lookAtCursor() makes the character's eyes follow the mouse cursor across the screen.
const character = await Vrm.findByName("MyAvatar");
await character.lookAtCursor();
A typical pattern is to enable cursor tracking when the character is idle and disable it during drag or other interactions:
character.events().on("state-change", async (e) => {
if (e.state === "idle") {
await sleep(500);
await character.lookAtCursor();
} else if (e.state === "drag") {
await character.unlook();
}
});
Use unlook to disable look-at behavior, or lookAtTarget to track a specific entity instead.