Property | Description |
---|---|
Character Name | The display name of your avatar NPC. This name appears in a name tag when the avatar is in a world. |
Spawn on Start | Set to true to spawn the NPC into the world when the world starts. Otherwise, the NPC must be spawned in using TypeScript. For more information, see Spawning for Scripted Avatar NPCs. |
Edit Avatar | Click this button to edit the avatar’s appearance. See below. |
Refresh | Click this button after you have edited your avatar’s appearance to refresh it in this world. See below. |
export const ExperimentalCodeBlockEvents = {
/*
* Triggered when the NPC disengages from the player.
*/
OnNpcDisengagePlayer: new CodeBlockEvent<[player: Player, npc: Entity]>(
'OnNpcDisengagePlayer',
[PropTypes.Player, PropTypes.Entity],
),
/*
* Triggered when the NPC engages with the player.
*/
OnNpcEngagePlayer: new CodeBlockEvent<[player: Player, pc: Entity]>(
'OnNpcEngagePlayer',
[PropTypes.Player, PropTypes.Entity],
),
/*
* Triggered when the NPC's engagement phase with player changes.
*/
OnNpcEngagementPhaseChangedEvent: new CodeBlockEvent<
[npc: Entity, phase: NPCEngagementPhase]
>('OnNpcEngagementPhaseChanged', [PropTypes.Entity, PropTypes.Number]),
/*
* This event is raised when the player speaking to LLM's mic level changes
*/
OnPlayerMicLevelUpdate: new CodeBlockEvent<
[player: Player, micLevel: number]
>('OnInternalOnlyPlayerMicLevelUpdate', [PropTypes.Player, PropTypes.Number]),
};
/**
* Represents an AI NPC's engagement phase with the user.
* @privateRemarks
* Must remain in sync with AelEngagementPhase enum in AelAPIEnums.cs AND
* NPCEngagementPhase in NpcEngagementPhaseChangedEvent.cs
*/
export enum NPCEngagementPhase {
/**
* The NPC is idle.
*/
NPCIdle = 0,
/**
* The npc is listening to the user.
*/
NPCListening = 1,
/**
* The npcis about to respond to the user.
*/
NPCReacting = 2,
/**
* The npcis speaking to the user.
*/
NPCResponding = 3,
/**
* The npcfinished speaking and is yielding to the user.
*/
NPCYielding = 4,
/**
* The npcis idle and is still focused on waiting for the user.
*/
NPCFocusedIdle = 5,
}
/**
* An AI NPC gizmo, which manages interactions between an LLM powered NPC and players.
*/
export class NPCGizmo extends Entity {
/**
* Creates a human-readable representation of the NPCGizmo object.
* @returns A string representation of the NPCGizmo object.
*/
override toString() {
return `[NPCGizmo] (${this.id})`;
}
/**
* Request the NPC to add the player to the list of its recognized players.
*
* @param player - The player object to be added.
*/
addRecognizedPlayer(player: Player) {
bridgeInstance.invoke(BridgeMethod.AddRecognizedPlayer, this, player);
}
/**
* Request the NPC to remove the player from the list of its recognized players.
*
* @param player - The player object to be removed.
*/
removeRecognizedPlayer(player: Player) {
bridgeInstance.invoke(BridgeMethod.RemoveRecognizedPlayer, this, player);
}
/**
* Request the NPC to remove all the players from the list of its recognized players.
*/
removeAllRecognizedPlayers() {
bridgeInstance.invoke(BridgeMethod.RemoveAllRecognizedPlayers, this);
}
/**
* The player entity that represents the NPC.
*/
npcPlayer: ReadableHorizonProperty<Player | null> = {
get: () => {
return bridgeInstance.invoke(BridgeMethod.GetNPCPlayer, this);
},
};
/**
* Adds an item to the list of items of interest for the npc.
* @param item - The item to add.
*/
addItemOfInterest(item: Entity) {
bridgeInstance.invoke(
BridgeMethod.NPCAddItemOfInterest,
this,
item,
);
}
/**
* Removes an item to the list of items of interest for the AI npc.
* @param item- The item to remove.
*/
removeItemOfInterest(item: Entity) {
bridgeInstance.invoke(BridgeMethod.NPCRemoveItemOfInterest, this, item);
}