using Unity.XR.CoreUtils;
namespace UnityEngine.XR.Interaction.Toolkit.Utilities
{
///
/// Provides utility functions for locomotion of the XR Origin.
///
public static class LocomotionUtility
{
///
/// Gets the world space position of the projection of the camera position onto the XZ plane of the XR Origin.
/// This should generally be treated as the "user" position for the purposes of locomotion to a
/// destination position.
///
/// The XR Origin.
///
/// Returns the world space position of the projection of the camera position onto the XZ plane of the XR Origin.
///
public static Vector3 GetCameraFloorWorldPosition(this XROrigin xrOrigin)
{
var cameraInOriginSpacePos = xrOrigin.CameraInOriginSpacePos;
var cameraFloorInOriginSpacePos = new Vector3(cameraInOriginSpacePos.x, 0f, cameraInOriginSpacePos.z);
return xrOrigin.Origin.transform.TransformPoint(cameraFloorInOriginSpacePos);
}
}
}