如何获得从对象到空间映射的距离

问题描述 投票:1回答:1

我正在使用Unity 2017.4,HoloToolKit 2017.4.3,Vuforia和Hololens。如何计算虚拟对象到Hololens空间映射的距离?我只需要Z坐标中的距离,就像“地板上方多少米是我的物体”。

c# unity3d hololens
1个回答
1
投票

由于你没有提供太多信息,这是我的第一个想法。从物体到地面/天花板的Raycast并走远。

     RaycastHit hit = new RaycastHit();
     if (Physics.Raycast (transform.position, -Vector3.up, out hit)) {
         var distanceToGround = hit.distance;
     }
© www.soinside.com 2019 - 2024. All rights reserved.