Any chance to get a working oculus avatar example ?

Hi,

Tried to have a working version of PUN2 and oculus avatar sdk, but not working at all.
I'v fallowed tutorial and many video to understand PUN2. But facing same problem of other user trying PUN2 and Oculus quest...

I use Unity 2109.2.15f1 with last oculus SDK (regulary updated)

in OnLocalAvatarPacketRecorded() from PhotonAvatarView

Oculus.Platform.Core.IsInitialized() is always false
ovrAvatar.Initialized is always false too

DEBUG:

PhotonNetwork.InRoom = true and PhotonNetwork.CurrentRoom.PlayerCount = 2 in trace

I can see my hand and base localavatar, same from remoteuser except I can't see moving (hand, body)

Any chance to get a working basic version of this ? I only want use PUN2 on VR with Oculus Quest...
this tutorial not working for sure: demos-and-tutorials/oculusavatarsdk
public void OnLocalAvatarPacketRecorded(object sender, OvrAvatar.PacketEventArgs args)
		{
			//if (!PhotonNetwork.InRoom || (PhotonNetwork.CurrentRoom.PlayerCount < 2))
			//	return;
			
			Debug.Log("-----------OnLocalAvatarPacketRecorded-------Oculus.Platform.Core.IsInitialized() = "+Oculus.Platform.Core.IsInitialized());
			Debug.Log("-----------OnLocalAvatarPacketRecorded-------ovrAvatar.Initialized = "+ovrAvatar.Initialized);
			Debug.Log("-----------OnLocalAvatarPacketRecorded-------PhotonNetwork.InRoom = "+PhotonNetwork.InRoom);
			Debug.Log("-----------OnLocalAvatarPacketRecorded-------PhotonNetwork.CurrentRoom.PlayerCount = "+PhotonNetwork.CurrentRoom.PlayerCount);

			//if (!notReadyForSerialization) { Debug.Log("-----------OnLocalAvatarPacketRecorded = notReadyForSerialization--------------"); return; }
	
			using (MemoryStream outputStream = new MemoryStream())
			{
				BinaryWriter writer = new BinaryWriter(outputStream);
	
				var size = Oculus.Avatar.CAPI.ovrAvatarPacket_GetSize(args.Packet.ovrNativePacket);
				byte[] data = new byte[size];
				Oculus.Avatar.CAPI.ovrAvatarPacket_Write(args.Packet.ovrNativePacket, size, data);
	
				writer.Write(localSequence++);
				writer.Write(size);
				writer.Write(data);
	
				packetData.Add(outputStream.ToArray());
			}
		}

Thanks for help

Comments

  • Hi @ilanbps,

    Thank you for choosing Photon!

    You need to properly configure Oculus from the Unity Editor AND initialize Oculus platform yourself as early as possible.

    Example:
    using UnityEngine;
    using Oculus.Platform;
    using Oculus.Platform.Models;
    
    public class OculusScript : MonoBehaviour
    {
        private void Start() // or even Awake
        {
            Core.AsyncInitialize().OnComplete(OnInitializationCallback);
        }
    
        private void OnInitializationCallback(Message<PlatformInitialize> msg)
        {
            if (msg.IsError)
            {
                Debug.LogErrorFormat("Oculus: Error during initialization. Error Message: {0}",
                    msg.GetError().Message);
            }
            else
            {
                // Oculus should be initialized now
            }
        }
    
  • Hi Johntube,

    Thanks for reply, I'v added this script and Oculus.Platform.Core.IsInitialized() is True now but ovrAvatar.Initialized is always false. I'v checked the ovravatar script like photon tutorial nothing wrong

    What I'v missing :-(

    Thanks again and merry christmas !!!
  • Hi @ilanbps,

    I see now that OvrAvatar.IsInitialized was a workaround suggested in the tutorial page and not part of the original Oculus SDK.
    Did you try the tutorial without it? if you do not run into InvalidCastException issue then no need for the workaround.
    Also if you add it, you need to make sure to set it to true at some point, the tutorial suggests CombinedMeshLoadedCallback method.

    So I suggest:

    1) you try again without modifying OvrAvatar.cs at all (without adding IsInitialized public field)
    2) if you have InvalidCastException, add it and make sure to set it to true at some point.

    ---

    (could be unrelated, do the above first)
    Otherwise, if you have other issues:

    From official Oculus documentation
    After getting a user ID, we then can set the oculusUserID of the Avatar accordingly. The timing is important, because we have to set the user ID before the Start() function in OvrAvatar.cs gets called.

    The issue is probably a timing issue or a missing step.
    Apparently you need to set a UserId to OvrAvatar.
    And you need to do it before OvrAvatar.Start() is called.
    For local avatar already in the scene or already instantiated?
    using UnityEngine;
    using Oculus.Platform;
    using Oculus.Platform.Models;
    
    public class OculusInitScript : MonoBehaviour
    {
        public OvrAvatar myAvatar; // local avatar
    
        private void Awake()
        {
            myAvatar.gameObject.SetActive(false);
            Core.AsyncInitialize().OnComplete(OnInitializationCallback);
        }
    
        private void OnInitializationCallback(Message<PlatformInitialize> message)
        {
            if (message.IsError)
            {
                Debug.LogErrorFormat("Oculus: Error during initialization. Error Message: {0}",
                    message.GetError().Message);
            }
            else
            {
                Users.GetLoggedInUser().OnComplete(GetLoggedInUserCallback);
            }
        }
    
        private void GetLoggedInUserCallback(Message<User> message)
        {
            if (message.IsError) 
            {
                  Debug.LogErrorFormat("Oculus: Error when getting logged in user. Error Message: {0}",
                    message.GetError().Message);
            } 
            else
            {    
                myAvatar.oculusUserID = message.Data.ID.ToString();
                myAvatar.gameObject.SetActive(true);
            }
        }
    

    In case OvrAvatar is attached to a prefab that will be instantiated using PUN, then make sure to set the UserId just post instantiation. You probably want to synchronize UserId and set Photon UserId to the same UserId as Oculus.

    Recommended: Use Photon Authentication with Oculus.
    Or at least set the Photon UserId to the Oculus UserId before connecting to Photon.

    In the PhotonAvatarView custom script created in the tutorial here:

    Replace:
    public void Start()
    {
        photonView = GetComponent<PhotonView>();
    
        if (photonView.IsMine)
        {
            ovrAvatar = GetComponent<OvrAvatar>();
            ovrAvatar.RecordPackets = true;
            ovrAvatar.PacketRecorded += OnLocalAvatarPacketRecorded;
    
            packetData = new List<byte[]>();
        }
        else
        {
            remoteDriver = GetComponent<OvrAvatarRemoteDriver>();
        }
    }
    

    with
    private bool initialized;
    
    private void OnEnable()
    {
        if (this.initialized)
        {
             return;
        }
        photonView = GetComponent<PhotonView>();
    
        if (photonView.IsMine)
        {
            ovrAvatar = GetComponent<OvrAvatar>();
            this.ovrAvatar.oculusUserID = this.photonView.Owner.UserId;
            ovrAvatar.RecordPackets = true;
            ovrAvatar.PacketRecorded += OnLocalAvatarPacketRecorded;
    
            packetData = new List<byte[]>();
        }
        else
        {
            remoteDriver = GetComponent<OvrAvatarRemoteDriver>();
        }
        this.initialized = true;
    }
    
  • Hey JohnTube,

    Thanks for reply, yes tried to remove the Initialized= true on OvrAvatar and same problem, no error but no poses streamed. I already tested oculus ID but some other maner of you without success.

    I try your code now, thanks again !!!
  • Finally coming back to trying this Oculus Avatar tutorial after the holidays, and because I was getting nowhere fast. @ilanbps did that sort your issue? Do you have it working in Unity now?.
    Thanks @JohnTube for the extra suggestions. Is it possible to update the tutorial with some of this info. I've yet to hear of anyone that has a basic working setup from the tutorial for an Oculus GO/Quest usecase ... I haven't tried it on the Rift. In fact is there a unity example project that could be created for download? This Oculus Avatar Tutorial question has been a regular on the forum and never truly answered from what I can tell.

    Rgds Daniel
  • Finally coming back to trying this Oculus Avatar tutorial after the holidays, and because I was getting nowhere fast. @ilanbps did that sort your issue? Do you have it working in Unity now?.
    Thanks @JohnTube for the extra suggestions. Is it possible to update the tutorial with some of this info. I've yet to hear of anyone that has a basic working setup from the tutorial for an Oculus GO/Quest usecase ... I haven't tried it on the Rift. In fact is there a unity example project that could be created for download? This Oculus Avatar Tutorial question has been a regular on the forum and never truly answered from what I can tell.

    Rgds Daniel

    Hi,

    I gave up because I can't get it to work with the Oculus SDK. I bought Humanoid VR on the store which works very well with PUN2 !
    it is very configurable and works very well with the Quest. I was able to test a meeting room with 4 Quest headsets pun 2 and photon voice 2 too without problem... you can custom avatar, hands poses, very quickly and simply...


  • Thanks @ilanbps its a real shame the Oculus Integration doesn't work (based without evidence to the contrary) with Photon. Would be worth Photon even taking that tutorial down rather than others wasting their time.
  • Just wanted to chime in that, after a couple of weeks (not full time) futzing around with the PUN+Oculus Integration, (I was making progress, but it felt real slow), I stumbled onto this thread, and paid $100 for HumanoidVR on the asset store. It's full of magic (I have no idea how most of it is working, which may be a problem later), but I had a 100% working networked multiplayer VR project in less than an hour. Very impressive, and I can finally feel like I'm making some actual progress.
Sign In or Register to comment.