Welcome to the Oculus Developer Forums!

Your participation on the forum is subject to the Oculus Code of Conduct.

In general, please be respectful and kind. If you violate the Oculus Code of Conduct, your access to the developer forums may be revoked at the discretion of Oculus staff.

Multiplayer with OVRPlayerController prefab and center eye issue

saprophagistsaprophagist Posts: 5
NerveGear
edited November 2016 in Unity Development
Hi!
I'm trying to make a multiplayer application using Unity 5.4.1p1 with Oculus 1.10.0.308075. Using Unet for network management and use OVRPlayerController prefab as spawn info > player prefab. Problem is, when i create a session and load first scene by clicking a button at lobby scene, center eye anchor transforms x rotation doubles somehow. If i click create session button on a panel (center eye rotation ~= x: 24 y:0 z:0), at the loaded level center eye x rotation becomes ~49. Meanwhile left and right eye cameras x rotations are ok (~24).

What can be the reason? What can be the solution?

Comments

  • vrdavebvrdaveb Posts: 1,596 Oculus Staff
    There is a known bug in Unity where it latches the current tracking pose in the tracking reference frame for Cameras that are enabled after the Awake method. You can counteract this by setting the pose of OVRCameraRig.trackingSpace. Alternatively, you could pre-create a pool of OVRPlayerController instances in Awake and later assign them instead of spawning them. Does either of those approaches work for your use case?
  • saprophagistsaprophagist Posts: 5
    NerveGear
    I think settings pose for OVRCameraRig.trackingSpace with UNITY_EDITOR directive should do the trick in my case.

    Thanks!
  • saprophagistsaprophagist Posts: 5
    NerveGear
    Setting the rotation of OVRCameraRig.trackingSpace solves visual problem, however OVRCameraRig and CenterEyeAnchor differs and this causes a lapse in movement direction.
  • vrdavebvrdaveb Posts: 1,596 Oculus Staff
    Does it help to change OVRPlayerController.HmdRotatesY?
  • saprophagistsaprophagist Posts: 5
    NerveGear
    edited November 2016
    It will but hmd have to rotate Y because it is a fps type application.
    Update: This option only enables / disables rotation of character with hmd. Doesn't affect the distorted synch between OVRCameraRig and modified trackingSpace.
  • vrdavebvrdaveb Posts: 1,596 Oculus Staff
    When HmdRotatesY is enabled, the OVRPlayerController rotates to match the CenterEyeCamera's world rotation. To get a different behavior, you would have to modify OVRPlayerController.cs.
  • treefortresstreefortress Posts: 20
    Brain Burst
    edited November 2016
    I'm a bit confused with why you guys are pinning this on Unity, when the behavior has existed for 2months+ now, and does not occur in either SteamVR or PSVR w/ Unity. 

    The amount of man-hrs being wasted by this bug must be in the several hundreds by now, if not thousands... come on, fix it. I reported it to these forums back in early September.
  • saprophagistsaprophagist Posts: 5
    NerveGear
    Found the solution just now. Just added an empty game object as the parent of CenterEyeAnchor. Only this solves the problem. I don't have to change its rotation or anything. Gaze pointer is at right place. Movement direction is ok.. Funny!! :smiley:

  • vrdavebvrdaveb Posts: 1,596 Oculus Staff
    @treefortress, are you saying the bug doesn't occur with Unity 5.4's built-in support for OpenVR or PSVR? It does appear to be in the vendor-agnostic part of Unity's built-in VR support. The problem is that if a new Camera comes online in Start, a frame of tracking data gets applied to its pose before it can latch that pose as its local reference frame for subsequent tracking frames. We are working with Unity to defer the application of tracking data until after the Camera's initial pose has been latched.
  • vrdavebvrdaveb Posts: 1,596 Oculus Staff
    edited November 2016
    I took a quick look at this and the problem is that Unity isn't marking the Camera's pose as immutable as soon as it's enabled. If a script (such as OVRCameraRig) tries to set a VR Camera's pose in the first frame after it's been enabled, the setting prevails and gets latched as the Camera's new reference frame. The intended behavior is for the Camera to immediately latch its pose and make it immutable to scripts when it's enabled with VR support. For now, you can work around this by modifying OVRCameraRig.cs. If OVRCameraRig.usePerEyeCameras is true, comment out the lines in the following that refer to centerEyeAnchor. Else comment out the lines that refer to left/rightEyeAnchor. We'll ship a slightly more robust code change in an upcoming copy of the Utilities and work with Unity to get the root issue fixed.

    		trackerAnchor.localRotation = tracker.orientation;
    		centerEyeAnchor.localRotation = VR.InputTracking.GetLocalRotation(VR.VRNode.CenterEye);
            leftEyeAnchor.localRotation = monoscopic ? centerEyeAnchor.localRotation : VR.InputTracking.GetLocalRotation(VR.VRNode.LeftEye);
    		rightEyeAnchor.localRotation = monoscopic ? centerEyeAnchor.localRotation : VR.InputTracking.GetLocalRotation(VR.VRNode.RightEye);
    		leftHandAnchor.localRotation = OVRInput.GetLocalControllerRotation(OVRInput.Controller.LTouch);
            rightHandAnchor.localRotation = OVRInput.GetLocalControllerRotation(OVRInput.Controller.RTouch);
    
    		trackerAnchor.localPosition = tracker.position;
    		centerEyeAnchor.localPosition = VR.InputTracking.GetLocalPosition(VR.VRNode.CenterEye);
    		leftEyeAnchor.localPosition = monoscopic ? centerEyeAnchor.localPosition : VR.InputTracking.GetLocalPosition(VR.VRNode.LeftEye);
    		rightEyeAnchor.localPosition = monoscopic ? centerEyeAnchor.localPosition : VR.InputTracking.GetLocalPosition(VR.VRNode.RightEye);
            leftHandAnchor.localPosition = OVRInput.GetLocalControllerPosition(OVRInput.Controller.LTouch);
            rightHandAnchor.localPosition = OVRInput.GetLocalControllerPosition(OVRInput.Controller.RTouch);
  • treefortresstreefortress Posts: 20
    Brain Burst
    That's correct, our code always enabled the CameraRig on Start(), and it worked great with PSVR and with StreamVR for months. It wasn't until we implemented the Oculus Rig, that we began seeing this really strange behavior.

    So I can't speak to the details behind it, only can say this is the only platform it occurs on and it's very annoying and must've wasted many peoples time. 

    Thanks for the workaround, will test it out!  
  • mythicalcitymythicalcity Posts: 9 Oculus Start Member
    Hi, we're having the same issue using Photon to instantiate our player. Tried the above code change but it didn't do anything. Using Unity 5.4.3.  are there other steps to perform or specific version numbers of oculus or unity that this fix will work with?
  • vrdavebvrdaveb Posts: 1,596 Oculus Staff
    If the Camera is being instantiated by Photon, then Photon is probably setting its position/orientation due to the same Unity bug. Try disabling it immediately after instantiation, setting transform.localPosition=Vector3.zero; transform.localRotation=Quaternion.identity, and then re-enabling it a frame later.
  • kendromekendrome Posts: 4
    NerveGear
    Did anyone get a working solution for this? I tried both of vrdaveb's suggestions and neither one works for our project.
  • lpug21lpug21 Posts: 5
    NerveGear
    edited January 2017
    This has been determined to be a bug within Unity itself. We should have a fix for this in the Oculus Utilities 1.11 release due out by 1/26/17.
    Hey imperativity, any movement on this front?  Keen for this issue to be resolved in something I'm looking to deploy in a few weeks.
  • Aleksey33Aleksey33 Posts: 20
    Brain Burst
    Hi!
    Can you help me in next question ?

    I have an element that should always be displayed in front of me (you can see on the screenshots).  I created it in world space and added to it a separate chamber which renders it only.
    For a player I use OVRCamrig. But 
    it rotate the camera, which is located in a separate object. How do I lock the camera is not in OVRCamrig?
  • Aleksey33Aleksey33 Posts: 20
    Brain Burst
    Hi!
    Can you halp me in next question ?

    I have an element that should always be displayed in front of me (you can see on the screenshots).  I created it in world space and added to it a separate chamber which renders it only.
    For a player I use OVRCamrig. But 
    it rotate the camera, which is located in a separate object. How do I lock the camera is not in OVRCamrig?


  • Aleksey33Aleksey33 Posts: 20
    Brain Burst
    Hi!
    Can you halp me in next question ?

    I have an element that should always be displayed in front of me (you can see on the screenshots).  I created it in world space and added to it a separate chamber which renders it only.
    For a player I use OVRCamrig. But 
    it rotate the camera, which is located in a separate object. How do I lock the camera is not in OVRCamrig?


Sign In or Register to comment.