Hello, I am thinking of using ready player me for a multiplayer game. But I encountered a problem. There are so many scripts that I could not use the avatar I created outside of the avatar creator wizard scene. After creating the avatar, I want to select that or the avatar created before, and then show it in another scene, but unfortunately I could not do it. If there is someone who knows about this and can do it, can they help me with discord or other chat applications? I am in a very difficult situation.
Hi there,
There are several ways to pass data between scenes in Unity, and using PlayerPrefs is a simple and effective approach. If you’re new to PlayerPrefs
, this YouTube Tutorial (not affiliated with our project) gives a good overview of how PlayerPrefs
works.
To save the avatar URL when the avatar is created, you can modify your GameManager
script like this:
private void OnAvatarSaved(string avatarId)
{
avatarCreatorStateMachine.gameObject.SetActive(false);
var startTime = Time.time;
avatarObjectLoader = new AvatarObjectLoader();
avatarObjectLoader.AvatarConfig = inGameConfig;
avatarObjectLoader.OnCompleted += (sender, args) =>
{
AvatarAnimatorHelper.SetupAnimator(args.Metadata.BodyType, args.Avatar);
DebugPanel.AddLogWithDuration("Created avatar loaded", Time.time - startTime);
};
avatarObjectLoader.LoadAvatar($"{Env.RPM_MODELS_BASE_URL}/{avatarId}.glb");
// Store and save the avatar URL
var avatarUrl = $"{Env.RPM_MODELS_BASE_URL}/{avatarId}.glb";
PlayerPrefs.SetString("AvatarURL", avatarUrl);
}
To load the avatar in another scene, you’ll need to retrieve the saved URL using PlayerPrefs
in your AvatarLoader
script (or wherever you’re loading the avatar in the new scene):
//Retrieve the saved avatar URL
string avatarUrl = PlayerPrefs.GetString(“AvatarURL”, “DefaultURL”);
Note that in the above example, “DefaultURL” is a placeholder URL that will be used if no avatar URL is found in PlayerPrefs
. You should replace it with an actual default URL or handle the case where the avatar URL is not found.
These instructions should ensure that the avatar URL is passed correctly between scenes, allowing you to load the same avatar without any issues.
I managed to load my game character into another scene, but the character just sits there and does nothing else. How can I make these avatars automatically gain movement commands and animations when they are initially loaded?
Hi there,
If you want the avatar to move, it would need a movement script. You can find examples in our Quickstart scene, the scripts are Third person movement script and Third person controller script. By looking into those scripts you can try to copy them or build one of your own.
What version of RPM SDK are you using?
Version 7.1.0 . But I can’t add yours script how can ı do . Sorry I am a new this kınd of things.
Hi there,
These scripts are a part of our Quickstart Scene in Unity, I recommend you look into the logic of how everything works in the Quickstart Scene.
If you can’t find the Quickstart Scene in your assets, in Unity go to → Tools → Ready Player Me → Integration Guides → Load Quickstart Scene.
When it comes to the shader issue, please check the following forum post for solution: Avatar appearing different in the build