简体   繁体   English

unity获取raycast的XYZ

[英]Unity get XYZ of raycast

I am not sure how to get the coordinates of a raycast.我不确定如何获取光线投射的坐标。 I have looked through the documentation and from what I gathered there is no methods that pull out the specific coordinates from a raycast.我查看了文档,从我收集到的内容中,没有任何方法可以从光线投射中提取特定坐标。 How do I go about getting the position of a raycast so other objects can move with it?如何获得光线投射的 position 以便其他对象可以随其移动?

Try this:尝试这个:

RaycastHit hit;
if (Physics.Raycast(ray, hit)){
    Debug.Log(hit.point)
}

The hit.point is the location where the ray hit (Vector3). hit.point是射线击中的位置 (Vector3)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM