单次射线检测

物理
Both Server and Client
Both Mobile and PC

进行一次射线检测,返回射线方向上命中的第一个实体,命中实体需要有碰撞组件,层级参若填空,则可以检测到地形

声明

func SingleRaycast(startPosition Vector3, direction Vector3, distance float, layerMask List<int>, includeTrigger bool, out var hitEntities entity<Entity>, out var hitPoints Vector3, out var hitDistances float, out var hitNormals Vector3)
go

参数

输入

名称 类型 描述
起点 Vector3 开始位置坐标
方向 Vector3 射线检测方向
距离 Float 射线检测距离,只接受正值
层遮罩 ListT_int 射线检测层遮罩,只有填入的层级会参与扫描,留空代表所有层级都参与扫描
包含触发器 Bool 是否可以扫描出触发器

输出

名称 类型 描述
命中实体 Entity 命中实体
命中点 Vector3 命中点坐标
命中距离 Float 命中点距离开始点距离
命中点表面法线 Vector3 命中表面法线