SpatialPointer offset when moving Rig

So I am using the Primary Spatial Pointer action data (VisionOSSatialPointerDevice) to drive my own input system. I am specifically using the “startRayOrigin”, “startRayDirection” and the “interactionRayRotation” while the pinch is maintained.

However I have noticed that this becomes completely offset if I teleport my XR Rig. The only way it properly work (in the simulator) is if I keep my rig at 0,0,0 and I don’t teleport or do anything. As soon as I teleport the data above is completely offset. Any ideas?

Hi there! Sorry to hear you’re having trouble.

Are you using the XR Interaction Toolkit? Another user ran into issues like this recently. I realized that I didn’t set up the sample scene properly, and needed to put the XR Interactor and RayOrigin transform under the CameraOffset transform in the XR rig. There is also some code in the samples that handles input which needs to account for this offset, as well. I’ve fixed things up for our next package release.

In the meantime, can you provide a little more context about how you are using the input device? If you are using your own scripts to take advantage of VisionOSSpatialPointerDevice, you will need to transform those inputs using that camera origin for things to line up. You can either just put your objects underneath the CameraOffset or XROrigin transform (depending on how you are using CameraOffset on other platforms) and use local positions, or apply that transform to get the correct location in world space. So for example:

var rayOrigin = offsetTransform.TransformPoint(primaryTouch.startRayOrigin);
var rayDirection = offsetTransform.TransformVector(primaryTouch.startRayDirection);
var ray = new Ray(rayOrigin, rayDirection);

where offsetTransorm is the XROrigin or CameraOffset. Does that make sense?

1 Like

We have our own input module so I was grabbing those values raw in my own script and passing them on, I didn’t realize those values were in local space. What you mention makes sense, I will give it a try and report back, thanks.

Oh what about interactionRayRotation? same thing?

1 Like

Works perfect after transforming to world space, thank you!