Hi everyone, how are you?
I’ve been struggling for a long time to integrate Ready Player Me natively into a desktop version of Unity. The goal is to allow players to customize their own characters within my game. However, I’m facing many issues, even when using the example scene. I can’t add a character controller to the generated avatar. I also don’t know which prefab is being used as the base for the player to customize in the code.
Has anyone successfully performed this native integration for desktop?
Thank you in advance.
Additional details:
- I’ve created a Unity project and imported the Ready Player Me SDK.
- I’ve added the “Ready Player Me Avatar” component to my player object.
- I’ve configured the API key and other settings in the component.
- I’ve tried adding a Character Controller component to the avatar object, but it doesn’t seem to work.
- I’ve tried looking for the prefab that is being used as the base for the avatar, but I can’t find it in the project.
Specific questions:
- How do I add a Character Controller to the generated avatar?
- Which prefab is being used as the base for the player to customize?
- How can I find this prefab in the project?
Any help or advice would be greatly appreciated.
Thank you!
Hello and welcome to the forum!
I’d suggest to start by taking a look at our QuickStart sample scene. You can find it under the Samples/QuickStart folder. The setup is mostly three game objects :
-
RPM Player: Here, you can find the Character Controller Componenet, in addition to all the script components responsible for the player movement, as shown in the screenshot below.
This is also available as a prefab, which you can find under the QuickStart/Prefabs folder. So you can drag and drop it into your scene and use it.
Under the Third Person Loader Script Component, you can replace the PreviewAvatar with your loaded avatar. This will make your avatar appear when you press play in the scene instead of the default preview avatar. You can disable or remove the previewAvatar game object then.
-
PreviewAvatar: as mentioned in the previous step, this is used as a default avatar to show in our quickstart scene, but you can replace it with your avatar.
-
RPM Camera Rig: Handling the camera movement following the input and the player’s movement.
This is mostly when you load your avatar in Editor so you can manually set it. If you want to do it at run time, then in this same scene, when you press play, you can click on Load my personal Avatar, paste your avatar URL, and load it.
To know more about how it is handled from the UI, you can check the PersonalAvatarLoader script and the Third Person Loader Script Component on the RPM Player game object.
1 Like
Thank you very much for your response. However, my question is about the native integration scene. I want to perform native implementation in my game. Using the computer’s selfie, the player generates their avatar and customizes it within the game. In the example scene, an avatar is generated that walks and speaks with its own animations. I am not able to customize this scene so that it generates an avatar controlled by the player.
You can find an example of customization of an avatar under our AvatarCreatorSamples. Then when the player finalizes the customization, you can disable the customization UI in your script and enable the environment you would like to use for the character to move around etc…
You can also load an entirely new scene. You need to make sure to save the Avatar URL in this case and pass it to the new scene when you load the character using PlayerPrefs or ScriptableObject for instance.
Hi, I’m working the same problem in two projects: a single player game using Game Creator, and a multiplayer project using Smartfox).
I have an avatar chooser scene (the Native Integration example) and a game arena scene.
Game Creator: I have the robot mesh that is the Player prefab. This has its Player controller which is 75% unity and some GC components.
Smartfox (SF2X): since the player motion needs to be synced over a network, I use one of my downloaded single-mesh Ready Player Me avatars as my default prefab and just replace the Animator with Smartfox’s from the Shooter example, and the SF2X Player Controller script. I posted a topic just now to work a mesh transfer problem.
Process:
TL;DR: basically, download a game-ready version of your native integration prefab using the model ID from the native integration example + a config file, and copy the skinned mesh onto your own prefab with its own player controller.
Here’s my download code snippets adapted from the RPM Photon example:
private string rpmURL;
private GameObject lqAvatar;
[SerializeField] private AvatarConfig config;
public void SetPlayer()
{
// load the medium res avatar, then transfer mesh to Game Creator armature
Debug.Log("avatar URL is " + rpmURL);
if (rpmURL.Length > 0)
{
AvatarObjectLoader loader = new AvatarObjectLoader();
loader.LoadAvatar(rpmURL);
loader.AvatarConfig = config;
loader.OnCompleted += (sender, args) =>
{
GameObject targetPrefab = this.gameObject;
if (VariablesManager.ExistsGlobal("avatar_model"))
{
//switchMeshActionSet.Execute(); // post-load actions in game.
AvatarMeshHelper.TransferMesh(args.Avatar, gameObject, null);
}
else
{
Debug.LogError("Error: something wrong with avatar id URL or model.");
}
};
}
}
1 Like
Thank you @XyrisKenn for sharing your solution ![:slight_smile: :slight_smile:](https://emoji.discourse-cdn.com/twitter/slight_smile.png?v=12)
I also see the AvatarMeshHelper.TransferMesh
method issue is solved in this other thread: Using AvatarMeshHelper in Unity - #2 by XyrisKenn