Skip to content

格式

typescript
RaycastHit.point

所属类: RaycastHit

描述

(只读)射线与碰撞器在世界空间中碰撞点。

该方法返回射线与物体相交的点的坐标。

参数

参数名类型描述

返回值

类型描述
Vector3在世界空间中碰撞点

代码示例

typeScript
class New_TypeScript
    extends Component {

        private boxCollider:BoxCollider;
        private ray:Ray;

    OnStart(): void {
        
        this.boxCollider = this.gameObject.GetComponent<BoxCollider>(BoxCollider);

    }

    OnUpdate(): void {

        //创建一条从(0,0,0)射向Y轴正方向的射线
		this.ray = new Ray(new Vector3(0,0,0),new Vector3(0,1,0));
        let hit = this.boxCollider.Raycast(this.ray,10000)
        hit.point;
       
    }
}