2D

private void OnTriggerEnter2D(Collider2D other)

{

if (other.gameObject.GetComponent())

{

hitPos = other.bounds.ClosestPoint(transform.position);

print("碰撞点" + hisPos);

}

}

 

3D

other.gameObject.GetComponent().ClosestPointOnBounds(transform.position);

 

注意这种方法不推荐单场景里过多使用,会产生大量的GC 影响帧率

 

好文阅读

评论可见,请评论后查看内容,谢谢!!!评论后请刷新页面。