3d 获取平面上单击位置的矢量3

3d 获取平面上单击位置的矢量3,3d,unity3d,physics,raycasting,mouse-position,3d,Unity3d,Physics,Raycasting,Mouse Position,我想用鼠标点击一个三维平面。执行此操作时,我希望它返回我单击的位置的矢量3。当我使用: Vector3 point = Camera.main.ScreenToWorldPoint(Input.mousePosition); 然后,它给出了平面中心的向量3。不是我想要的。我希望它位于我单击的位置 我正在尝试创建一个光线(Camera.screenpointoray)并使用Physics.Raycast,但它只返回一个bool,而不是它实际到达的位置 在过去的3个小时里,我一直在阅读其他人的问题

我想用鼠标点击一个三维平面。执行此操作时,我希望它返回我单击的位置的
矢量3
。当我使用:

Vector3 point = Camera.main.ScreenToWorldPoint(Input.mousePosition);
然后,它给出了平面中心的向量3。不是我想要的。我希望它位于我单击的位置

我正在尝试创建一个
光线
Camera.screenpointoray
)并使用
Physics.Raycast
,但它只返回一个
bool
,而不是它实际到达的位置


在过去的3个小时里,我一直在阅读其他人的问题……我在这里遗漏了什么?

好吧,你就快到了!你需要使用的是

编辑
这应该对你有帮助

Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition); //Convert mouse position to raycast
RaycastHit hit; //Create a RaycastHit variable to store the hit data into
Vector3 clickedPosition; //Create a vector3 variable to store the clicked position in

if (Input.GetMouseButtonDown (0) && Physics.Raycast (ray, out hit, 1000)) //If the user clicks the left mouse button and we hit an object with our raycast then
{
    clickedPosition = hit.point; //Store the hit position into the clicked position variable
}

就这么简单:)

不,不是。我不是在找布尔值,我是在找向量3。是的,它是。请友好地仔细阅读这一页:
Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition); //Convert mouse position to raycast
RaycastHit hit; //Create a RaycastHit variable to store the hit data into
Vector3 clickedPosition; //Create a vector3 variable to store the clicked position in

if (Input.GetMouseButtonDown (0) && Physics.Raycast (ray, out hit, 1000)) //If the user clicks the left mouse button and we hit an object with our raycast then
{
    clickedPosition = hit.point; //Store the hit position into the clicked position variable
}