Skip to main content
Anton111111
Inspiring
March 14, 2024

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)

 

    This topic has been closed for replies.

    9 replies

    Inspiring
    March 19, 2024

    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.

    JeffNik
    Honored Contributor
    March 21, 2024

    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
    Inspiring
    March 21, 2024

    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;
                    });
            }
        }
    }
    Anton111111
    Inspiring
    March 22, 2024

    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
    Honored Contributor
    March 24, 2024

    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.

    Anton111111
    Inspiring
    March 25, 2024

    Yep i'm sure. And i have issue only sometimes. 

    Anton111111
    Inspiring
    March 25, 2024

    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. 

    JeffNik
    Honored Contributor
    March 25, 2024

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

    Anton111111
    Inspiring
    March 25, 2024

    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;
                    });
            }
        }
    }