Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
Anton111111's avatar
Anton111111
Expert Protege
2 years ago

How understand what user use (seated or standing position)?

I want to show panel in front of user face. But when i try get OVRManager.profile.eyeHeight i've get about 1.65. How i understand it's some default value for standing position. 

And how to get real eye position of user? Or maybe just undertand is user seating or standing and use two constants.  But i can't find how understanding what mode user select (seated/without moving or standed)

 

9 Replies

Replies have been turned off for this discussion
  • Some of the games I've worked on provide internal values for both standing and seating positions. They measure the head GameObjects world position center, with values typically ranging from 1.10 to 1.40 for seated positions and above 1.40 for standing positions.

  • Under OVRCameraRig/TrackingAnchor is a "CenterEyeAnchor" object that gets updated with the real-time position of the bridge of your nose. That should give you a good position to base your panel position from.

    • Anton111111's avatar
      Anton111111
      Expert Protege

      Thanks πŸ˜‰ i found exactly the same soultion myself πŸ˜‰

      public class EyeLevel : MonoBehaviour
      {
          private void OnEnable()
          {
      #if !UNITY_EDITOR
              PlaceToEyeLevel();
      #endif
          }
      
          private void PlaceToEyeLevel()
          {
              if (App.Instance.OVRCameraRig.centerEyeAnchor != null)
              {
                  Transform centerEyeAnchor = App.Instance.OVRCameraRig.centerEyeAnchor;
                  var calculatedY = (
                      centerEyeAnchor.position + centerEyeAnchor.forward * transform.position.z
                  ).y;
      
                  transform.localPosition = transform
                      .localPosition
                      .Let(it =>
                      {
                          it.y = calculatedY;
                          return it;
                      });
              }
          }
      }
  • In additional i noticed that this solution sometimes works not good. CenterEyeAnchor. Has wrong Y (when i sit it returns wrong Y like i stand)

    • JeffNik's avatar
      JeffNik
      MVP

      It's always right for me. If you want CenterEyeAnchor.transform.y to be the height from the floor, are you sure you're setting the tracking mode on the OVRManager to "floor"? Also - check that there's not some weirdness going on with the y offsets in the transforms of any parent transforms.

  • I've made a little test. 

    I add the following code to write Y from centerEyeAnchor.position.y :

    private void LateUpdate()
        {
            if (App.Instance.OVRCameraRig.centerEyeAnchor != null)
            {
                Transform centerEyeAnchor = App.Instance.OVRCameraRig.centerEyeAnchor;
    
                DebugArea.Info(
                    "centerEyeAnchor: {0} {1}",
                    centerEyeAnchor.position.y,
                    centerEyeAnchor.forward.y
                );
            }
        }

     

    And i see that Y changed from 1.01 to 1.7 when i rotate headset around X without changes headset position. And this is cause of my issue. 

  • I'm happy to try your project in my environment if you want to make it available to me.

  • My issue easy fixed. When i calculate Y i add forward vector and it afcouse move Y πŸ˜‰ It because i copy this part from another part of my code and forgot to delete it. 

    Here is fixed component: 

    public class EyeLevel : MonoBehaviour
    {
        private void OnEnable()
        {
    #if !UNITY_EDITOR
            PlaceToEyeLevel();
    #endif
        }
    
        private void PlaceToEyeLevel()
        {
            if (App.Instance.OVRCameraRig.centerEyeAnchor != null)
            {
                Transform centerEyeAnchor = App.Instance.OVRCameraRig.centerEyeAnchor;
                var calculatedY = (
                    centerEyeAnchor.position + new Vector3(0f, 0f, transform.position.z)
                ).y;
    
                transform.localPosition = transform
                    .localPosition
                    .Let(it =>
                    {
                        it.y = calculatedY;
                        return it;
                    });
            }
        }
    }