How to get started with the Avatar API in Unity

Last month, we released the Avatar API – our avatar interoperability layer that improves avatar performance and integration flexibility. We have already seen Ready Player Me partners use it to make their games run smoother or to generate 2D user profile pictures.

The Avatar API makes changing Avatar Config simple, regardless if you're building a web experience or a game in Unity. We partnered with Dinesh Punni from Immersie Insiders to go over the API's features and using it with Unity.

How to use the Avatar API

All you need to get started with the Avatar API with an avatar ID that ends with the GLB file extension. You can get an avatar URL to your existing avatar from the My Avatars section of the Ready Player Me Hub or by creating it on the demo subdomain. It should look like this: https://api.readyplayer.me/v1/avatars/6185a4acfb622cf1cdc49348.glb

Avatar API allows you to change the Avatar Config by adding parameters to the URL. For example, to change the mesh's level of detail, you have to add ?meshLod=2 at the end of the link: https://api.readyplayer.me/v1/avatars/6185a4acfb622cf1cdc49348.glb?meshLod=2.

Currently, you can use the following parameters, with more to come in future releases:

  • meshLod – control the triangle count of the returned avatar
  • textureSizeLimit – set the upper limit for texture resolution in pixels of any texture in the avatar
  • textureAtlas – generate a texture atlas of the desired resolution
  • morphTargets – comma-separated list of individual morph targets or morph target standard groups to include on the avatar
  • pose – define the pose for a full-body avatar
  • useDracoMeshComparassion – reduce the file size by compressing output avatars with Draco mesh compression
  • useHands – toggle hands for half-body VR avatars

You can see a list of all available properties in our developer docs.

2D avatar render created using the Avatar API

Getting 2D renders through the Avatar API

By changing the file extension from GLB to PNG, you can export a 2D render of the avatar using the Render API. There are a couple of parameters that let you change the render background and avatar's expression:

  • scene – the name of the portrait type to render (full-body, half-body, transparent, etc.)
  • blendShapes – map of 3D meshes to their blend shapes (changing avatar's expression)

See the list of all available properties for 2D avatars.

Access metadata of an avatar

Avatar API also allows you to see the following metadata of an avatar:

  • bodyType (full-body or half-body)
  • outfitGender (masculine or feminine)
  • outfitVersion (depends on the outfit)
  • skinTone (provided as a hex value – you can use it for setting the skin tone of custom hands for VR avatars)
  • createdAt
  • updatedAt

Using the Avatar API with the Unity SDK

If you're using the Ready Player Me Unity SDK, you can access Avatar API's features directly through the Unity editor. You can also take advantage of the Scriptable Objects and dynamically change the Avatar Config based on the gameplay. It can be used for things like distance-based rendering of avatars with a variable mesh LOD. You can use one of the default Avatar Configs or create a custom one that fits your needs.

Get started with the Avatar API and Ready Player Me

You have everything that's needed to get started with the Avatar API. Head to the developer docs for more detailed instructions and to learn more about integrating Ready Player Me avatars into your app or game. You can also read more about Avatar API from the Immersive Insiders team.

We spent seven years building a perfect 3D avatar system, so you don't have to. Ready Player Me avatars work on the web, mobile, and every platform that support Unity or Unreal Engine.

Join the growing list of over 5,000 Ready Player Me partners who integrate our avatars into their apps and games, including Animaze, Immersed, Spatial, and Hiber.

Ready Player Me is free to use for users and developers. Become a Ready Player Me partner to use our avatars in your commercial app or game.