Skip to content

XrNavigation teleport lands short of target position #8408

Description

@willeastcott

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

  1. Run the XR Menu example in VR
  2. Point at a spot on the ground and teleport
  3. 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.

Metadata

Metadata

Assignees

Type

Fields

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions