Ready Player Me Avatar Integration
Principle
This addon allows the integration of Ready Player Me half-body avatars.
Full body avatars adaptations have not been added yet, but the code could be easily adapted to support them if needed.
Features
Avatar add-on compatibility
This addon is compatible with the avatar addon.
As long as an AvatarRepresentation
component is present in the parent hierarchy of RPMAvatarLoader
, this compatibility allows, among other things:
- listener to be warned that the avatar is loaded
- to add the loaded ReadyPlayerMe avatar to a LOD Group.
RPMAvatarLoader
can be used alone though, which is useful for UI, avatar selection, ...
Avatar edits
Besides, this addon applies a few modification to loaded ReadyPlayerMe avatars. All these modifications are optional, and which one should be applied can be selected with the avatarOptionalFeatures
mask on the RPMAvatarLoader
class:
HideRPMHands
: If selected, ReadyPlayerMe hands will be hidden. Relevant if another hand representation solution is provided, like the hands used in the VRShared-based sample,OptimizeAvatarRenderers
: Ensure the ReadyPlayerMe avatar displays nicely in an URP context and cost less on the performance side (no shadows, ...),DetectColorForAvatarDescription
: Analyse the avatar textures to ensure that RPMAvatarInfo.AvatarDescription includes the color. Useful to change hand colors to match the skin, or to use the hair and cloth color to customize a simplified LOD representation of the avatar,EyeMovementSimulation
: Connect the ReadyPlayerMe avatar eyes to the eye simulation system, so that they follow objects with aGazeTarget
component` that are near the avatar,LipSynchronisation
: Connect the face mesh blendshape to Oculus lip synchronization. Note that on MacOS and webGL, this is not possible, and will be replaced by a simple voice level detection system,LipSyncWeightPonderation
: The Oculus Lip sync blendshape weight produces too high values for ReadyPlayerMe avatar meshes. So it has to be adapted, either by changingOVRLipSyncContextMorphTarget
code (see here), or by using this option which fix the values inLateUpdate
,EyeBlinking
: apply an eye blinking script provided by ready Player Me on the avatar, so that they blink naturally,OnLoadedSoundEffect
: use the SoundManager to play a sound on avatar download completion,DownloadThrottling
: use thePerformanceManager
to prevent several ReadyPlayerMe avatar download to happen at the same time (it could saturate the bandwidth, preventing proper network communication),
By default, all options are selected (AllOptions
value), but for instance to show the avatar in a simple selection UI, it is relevant to just select HideRPMHands
and OptimizeAvatarRenderers
options.
Cache system
If the same avatar is used several times in a scene, this addon offers a cache system that prevents redownloads of the same avatar.
If the same avatar is downloaded a second time, a copy of the first one will be instantiated if it is already available.
If the first one is still downloading, the second one will wait a bit (up to maxSameDownloadWaitTime
, 10 seconds by default).
Note that ReadyPlayerMe can delete some avatar game objects if the same url is used a second time: the cache system of the addon prevents this, but if 2 downloads occur at the same time, and the first one takes more than maxSameDownloadWaitTime
to finish, a second download will trigger, erasing in the process the first avatar upon completion. This scenario should not happen out of very special cases (crowded scene, with a lot of duplicated), but to ensure it is not a problem, it is possible to always create a copy of the avatar, to prevent ReadyPlayerMe from destroying it, at the expense of spending time creating this copy.
To do so, simply check copyRPMLoaderAvatar
on the RPMAvatarLoader
component (unchecked by default).
RPMAvatarLibrary
It is possible to add in a scene a library of predownloaded avatars, available in the project as prefabs: this library component, RPMAvatarLibrary, contains a mapping between this prefab, and a fake URL that will use this prefab when loaded by the RPMAvatarLoader
Note that while you can fill its metadata field, mostly useful for the skintone in latest ReadyPlayerMe avatars, the library will try to detect the metadata automatically if not filled, so it is not mandatory to fill the metadata entry.
This RPMAvatarLibrary
simply prefills the avatar cache with the referenced prefabs, as if they had been actually downloaded once.
Install
This add-on requires the Ready Player Me UPLM package to work.
To do so, as described in ReadyPlayerMe documentation, install the following git package:
https://github.com/readyplayerme/rpm-unity-sdk-core.git
It has been tested with the version 3.3 of the Ready Player Me core package (com.readyplayerme.core).
Dependencies
- Avatar addon version 1.0.0
- Ready Player Me 3.3
- Oculus.Lipsync (version included in the Avatar add-on)
Demo
Demo scenes can be found in the Assets\Photon\FusionAddons\RPMAvatar\Demo\Scenes\
folder.
The RPMAvatarLoading
scene loads several ReadyPlayerMe avatars :
- an avatar specified with an URL provided by the ReadyPlayerMe online editor and user an UserInfo component to load and synchronize on the network its avatar url,
- the same avatar to demonstrate the cache system,
- an offline avatar, not related to any Fusion's networked object (might be used in UI, ...).
- and an avatar prefab loaded thanks to a custom avatar URL and the
RPMAvatarLibrary
.
The RPMAvatar
scene uses the RPMNetworkRig
prefabs, which incorporates most needed features:
- it is compoatible with simple avatar url and RPM urls
- it provides a low poly fallback, which is colored by either the simple avatar or RPM avatar skin, clothes and hair colors
- it includes hand models, that will take the color of the avatar skin
- it provides a billboard last level of LOD
- it demonstrates the
EyeMovementSimulation
feature. The avatar's eyes follows theTarget
game object thanks to theGazeTarget
component. The avatar head and eyes containing aGazeTarget
, player will look at each others.
Download
This addon latest version is included into the addon project
Supported topologies
- shared mode
Changelog
- Version 1.0.1: Fix avatar V3 hair and clothes color detection
- Version 1.0.0: First release