I’m struggling with this a bit. Where are you finding ‘startDevicePosition’ that you use to calculate the corrected 1:1 input?
I’m attempting to detect a tap, identify the interaction position on a plane (the plane has a box collider), and then spawn a click effect prefab right at the interaction point. However, I’m finding I can’t accurately identify that interaction point. When I tap (in visionOS simulator) at a point such as (1, 0, 1), the interaction position seems to be slightly offset from the touch point.
I’m using the following code to get the touch data:
EnhancedSpatialPointerSupport.GetPointerState(activeTouches[0]);
When I tap at (1, 0, 1) and then check the interactionPosition from that touchData, I get the following:
(44.84, 15.03, 44.46)
At first I was really confused over this, but then I considered that maybe the scale of my volume camera is a factor. My Volume Camera dimensions are 30, 30, 30. So I tried dividing the interaction position x, y and z values by that scale factor. After doing that, I get:
(1.49, .50, 1.48)
This is much closer to the anticipated touch point of (1, 0, 1), but it appears to be offset by about 0.5 in all directions, and I’m not sure why.
I’m also finding that the further I look away on the plane and perform a tap, the greater the offset is. So there seems to be some link between my eye position, or possibly the “device position”? So I can’t simply subtract (0.5, 0.5, 0.5) from the interaction position to fix the issue… the offset seems to scale based on something, but I haven’t figured out what.
This post is the closest thing I have come across on these forums to this issue that I’m having. And I think what I’m chasing is the green interaction point from the gif that was posted. But I’m struggling to figure out the proper way to calculate that point.
Can anyone offer any insight on what I’m running into here? Or how to properly identify an interaction point such as (1, 0 , 1) when I’m confident I’m tapping at that location on a plane?
Attached is a photo that shows my mouse cursor at (1, 0, 1) performing a tap in the simulator along with the green tap effect that I’m spawning at the interaction position, after scaling it down by my volume camera’s dimension size. As you can see, the result is a click effect that is slightly offset from my actual click location. The second photo shows stopping at a breakpoint to display the contents of the touch data.
Thanks
Edit: I’ll also note that I’m using PolySpatial 1.1.4