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.