代码之家  ›  专栏  ›  技术社区  ›  jtth

Unity Hololens光标跟随用户视线偏离中心?

  •  1
  • jtth  · 技术社区  · 9 年前

    我基本上是在尝试使用自己的代码来完成BasicCursor及其相应的脚本Cursor。cs,使用 Microsoft Toolkit

    目前,我有光标跟随用户的视线,但它似乎偏离了中心。光标较低,位于用户实际凝视的左侧。有什么效果?

    // Do a raycast into the world based on the user's
    // head position and orientation.
    var headPosition = Camera.main.transform.position;
    var gazeDirection = Camera.main.transform.forward;
    
    RaycastHit hitInfo;
    Ray ray;
    Camera c = Camera.main;
    
    ray = c.ScreenPointToRay(headPosition);
    
    if (Physics.Raycast(headPosition, gazeDirection, out hitInfo))
    {
    
    
        // If the raycast hit a hologram...
            objHit = hitInfo.transform;
    
        // Move the cursor to the point where the raycast hit.
            this.transform.position = hitInfo.point;
    
        // Rotate the cursor to hug the surface of the hologram.
            this.transform.rotation = Quaternion.FromToRotation(Vector3.up, hitInfo.normal);
    }
    
    1 回复  |  直到 9 年前
        1
  •  1
  •   Draco18s no longer trusts SE    9 年前

    单位应该是1米。

    将视野设置为60度以获得最佳体验,我相信预制全息相机的视野为51度。

    我不知道为什么从米到英寸的转换会给你一个10次方的值(应该是大约39.37的倍数)