Content Creators
NPC Avatars

NPC Avatars

Display an avatar as an entity in a scene.

Create an avatar #

The following snippet creates an avatar with random wearables and body shape, and name “NPC”.

const myAvatar = engine.addEntity()
AvatarShape.create(myAvatar)

Transform.create(myAvatar, {
	position: Vector3.create(4, 0.25, 5)
})

When passing data to generate an AvatarShape, the following fields are required:

  • id: (required) Internal identifier for the Avatar

The following optional fields are also available:

  • name: Name to display over the Avatar’s head. Default: “NPC”.
  • bodyShape: String to define which body shape to use.
  • wearables: Array with list of URNs for wearables that the avatar currently has on. If wearables conflict (like two of them are hats), the last one in the list replaces the other.
  • emotes: Array with list of URNs for NFT emotes that the avatar is capable of playing
  • eyeColor: Color3 for the eye color (any color is valid)
  • skinColor: Color3 for the skin color (any color is valid)
  • hairColor: Color3 for the hair color (any color is valid)
  • talking: If true, it displays a green set of bars next to the name, like when players use voice chat in-world.
💡 Tip: See color types for more details on how to set colors.

Animations #

Avatars play default idle animations while still.

To play animations on the avatar, set the expressionTriggerId string to the name of the animation you want to play.

const myAvatar = engine.addEntity()
AvatarShape.create(myAvatar, {
	id: "",
	emotes: [],
	wearables: [],
	expressionTriggerId: "robot"
})

Transform.create(myAvatar, {
	position: Vector3.create(4, 0.25, 5)
})