Description
The XrNavigation script's teleportation feature doesn't properly account for the camera's local XZ offset from the navigation entity, causing the user to land short of the target position they were pointing at.
Steps to Reproduce
- Run the XR Menu example in VR
- Point at a spot on the ground and teleport
- Notice the camera ends up offset from where you were pointing
Expected Behavior
When teleporting, the user's camera (head position) should end up directly above the target location they were pointing at.
Actual Behavior
The teleportation "falls short" because the navigation entity is moved to the hit point without compensating for the camera's local position offset (from XR head tracking).
Technical Details
In WebXR, the camera entity's local position represents the user's physical head position within their play space. This offset can be significant (e.g., (0.3, 1.65, 0.5)).
The current code sets the navigation entity's position to the hit point:
this.entity.setPosition(hitPoint);
But because the camera has a local offset, the camera ends up at hitPoint + cameraLocalOffset instead of at hitPoint.
Solution
Subtract the camera's local XZ offset from the hit point before setting the navigation entity position, so the camera ends up directly above the target.
Description
The
XrNavigationscript's teleportation feature doesn't properly account for the camera's local XZ offset from the navigation entity, causing the user to land short of the target position they were pointing at.Steps to Reproduce
Expected Behavior
When teleporting, the user's camera (head position) should end up directly above the target location they were pointing at.
Actual Behavior
The teleportation "falls short" because the navigation entity is moved to the hit point without compensating for the camera's local position offset (from XR head tracking).
Technical Details
In WebXR, the camera entity's local position represents the user's physical head position within their play space. This offset can be significant (e.g.,
(0.3, 1.65, 0.5)).The current code sets the navigation entity's position to the hit point:
But because the camera has a local offset, the camera ends up at
hitPoint + cameraLocalOffsetinstead of athitPoint.Solution
Subtract the camera's local XZ offset from the hit point before setting the navigation entity position, so the camera ends up directly above the target.