标签:style blog http ar io color os 使用 sp
1 Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); 2 RaycastHit hit; 3 4 if (Physics.Raycast(ray,out hit,layermask)) 5 { 6 Vector3 dir = hit.point - Camera.main.transform.position; //dir为由摄像机指向摄像机到射线打到的点的向量 7 Vector3 forward = Camera.main.transform.forward; //指向摄像机正前方的单位向量 8 Debug.Log("Camera.main.ScreenToWorldPoint(Input.mousePosition) " 9 + Camera.main.ScreenToWorldPoint(Input.mousePosition) 10 + new Vector3(0, 0, (Vector3.Dot(dir, forward)))); //Vector3.Dot(dir, forward)为dir与forward的点乘,几何意义为dir在forward上的投影 11 Debug.Log("hit.point " + hit.point); 12 }
camera.ScreenPointToRay(),camera.ScreenToWorldPoint()与Raycast()
标签:style blog http ar io color os 使用 sp
原文地址:http://www.cnblogs.com/diamond/p/4168083.html