Meta Avatar Synch using unity Photon networking

The whole answer can be found below.

Please note: The Photon forum is closed permanently. After many dedicated years of service we have made the decision to retire our forum and switch to read-only: we've saved the best to last! And we offer you support through these channels:

Try Our
Documentation

Please check if you can find an answer in our extensive documentation on PUN.

Join Us
on Discord

Meet and talk to our staff and the entire Photon-Community via Discord.

Read More on
Stack Overflow

Find more information on Stack Overflow (for Circle members only).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

Meta Avatar Synch using unity Photon networking

basha
2022-02-15 07:43:38

Hi,

I'm using Pun for Multiplayer for oculus unity Project. along with avatar 2 SDK (meta avatar SDK) to get the profile avatar.

  • here i'm able to get profile avatar of mine inside the app.

  • but other can't see my avatar they are see me as their profile avatars only or vise versa. it means all avatars in multiplayer is same(device profile avatars).

Please help me how to synch the avatars as well as avatar event like rising hands ets.,

Comments

osamajeed
2022-03-22 12:38:12

You need to get the send the oculus user id to other users. I send it in the instantiation data of the PhtonNetwork.Instantiate() function.

Like this:

Int64 _userId = Convert.ToInt64(userId);    
object[] objects = new object[1] { _userId};    
PhotonNetwork.Instantiate("MyAvatar", position, rotation, 0, objects);    

You can get the logged-in user's id from Users.GetLoggedInUser() function. Like this:

bool _userIdComplete = false;    
IEnumerator getOculusUserId()    
    {    
        //initaliaze the ovr platform befor this if not already initialized. OvrPlatformInit.InitializeOvrPlatform()    
        Users.GetLoggedInUser().OnComplete(message =>    
        {    
            if (!message.IsError)    
            {    
                userId = message.Data.ID;    
            }    
            else    
            {    
                var e = message.GetError();    
                Debug.LogError(e.Message);    
            }    
            _userIdComplete = true;    
        });    
        while (!_userIdComplete) { yield return null; }    
    }    

And then you can get the id of this avatar entity from its instantiation data and then assign it to OvrAvatarEntity._userId.After this, call the LoadUser() function to load the avatar. Like this:

void Start(){            
    PhotonView photonView = GetComponent<PhotonView>();    
    object[] instantiationData = photonView.InstantiationData;    
    Int64 data_as_int = (Int64)instantiationData[0];    
    _userId = Convert.ToUInt64(data_as_int);    
    LoadUser();       
}    

Tobias
2022-03-25 10:35:47

Alternatively use the Custom Player Properties so share the Oculus ID or some other.

Back to top