


对场景中的碰撞体进行胶囊的投射,如果相交,返回碰撞体的raycasthit信息。
胶囊的描述:point1 ,point2为上下两个结束点,radius为半径。对胶囊做投射时,如果和碰撞体碰撞,raycasthit 结构返回碰撞信息。这可以用在光线投射无法满足要求时的情况下。例如要判断角色(有空间大小尺寸)是否和一个物体发生碰撞。
它不能检测到胶囊体之内的物体,也就是说发出射线的时候就已经包含在胶囊体内的话是不能被检测到的

投射球型物体来判断是否与场景中物体交互,返回 Raycasthit 信息。
它不能检测到起点半径之内的物体,也就是说发出射线的时候就已经包含在球半径内的话是不能被检测到的,如果要检测半径内的使用Physics.OverlapSphere来进行检测。
public static Collider[] OverlapSphere(Vector3 position, float radius);
返回球型半径之内(包括半径)的所有碰撞体
public static bool CheckSphere(Vector3 position, float radius);
与上面是同一个意思,只是返回bool值
网友评论