Jump to content

WVR_InAppRecenter doesn't work with HandTracking


vethetheth

Recommended Posts

Hi @vethetheth,

I created this script, let me know if it is ok for you?

using UnityEngine;

public class RecenterScript : MonoBehaviour
{
    public GameObject VROrigin;
    public GameObject Camera;

    public void Recenter()
    {
        var cameraLocalRot = Quaternion.Euler(0, Camera.transform.localEulerAngles.y, 0);
        Matrix4x4 camLoacalNow = Matrix4x4.TRS(Camera.transform.localPosition, cameraLocalRot, Vector3.one);
        var targetHeight = Camera.transform.position.y;
        var targetPos = new Vector3(Camera.transform.position.x, targetHeight, Camera.transform.position.z);
        Matrix4x4 TargetPos = Matrix4x4.TRS(targetPos, Quaternion.identity, Vector3.one);
        Matrix4x4 CameraRigWorld = TargetPos * Matrix4x4.Inverse(camLoacalNow);
        Vector3 XZPos = CameraRigWorld.GetColumn(3);

        VROrigin.transform.position = XZPos;
        VROrigin.transform.rotation = CameraRigWorld.rotation;
    }
}

I tested with Tutorial scene from VIU example scene.

You simply add the Recenter function to the button.

I made some modifications to the scene by adding VROrigin and move ViveCameraRig and VivePointers to its child.

image.png.274f6a33a64d96272cf5092b758588f0.png

Link to comment
Share on other sites

  • 2 weeks later...

 Hello @chengnay, sorry for the long absence without response. What we wanted to do with the recenter was : reset the rotation (it works perfectly with your code) and reset the position of the player to the center of our scene (we could use a 0,0,0 transform GameObject for example). We managed to do both separately but not at the same time. And the WVR_RECENTER of the API doesn't work with hand tracking. Thanks for your help in advance.

 

 

 

 

Link to comment
Share on other sites

Interop.WVR_InAppRecenter(WVR_RecenterType.WVR_RecenterType_YawAndPosition);

This line doest exactly what we need : it recenter the view, and it resets our position, the controller are fine too. But the hand tracking hands are not reset. I tried to deactivate the hand tracking / resetting their position so they can be at the good place after recentering but i couldn't make it work... Do you have an idea while they try to fix it internally ?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...