我基本上是在尝试使用自己的代码来完成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);
}