I am making a VR game where I would like to allow pressing the ‘A’ button on the left controller to move the camera towards wherever the right controller is pointed.
I am running the below inside of Update() in a script running in my camera object.
When I press the button, I see it start moving, and even though the direction seems to change when I change the location of the right controller, it is as if it is shifted somehow or I am converting incorrectly.
My goal is to simply get the location of the right controller, convert to world coordinates, and then move the camera towards it.
if (triggerAction.action.IsPressed())
{
UnityEngine.XR.InputDevice handR = InputDevices.GetDeviceAtXRNode(XRNode.RightHand);
handR.TryGetFeatureValue(UnityEngine.XR.CommonUsages.devicePosition, out Vector3 posR);
Vector3 vRightHandPosition = transform.TransformPoint(posR);
this.transform.position = Vector3.MoveTowards(this.transform.position, vRightHandPosition, 1.0f);
}
Can someone please give me an idea of what I am doing wrong?