import { _decorator, Component, geometry, Node, PhysicsSystem, Vec2, Vec3 } from 'cc';
const { ccclass, property } = _decorator;
@ccclass('sse2')
export class sse2 extends Component {
start() {
//获取节点的世界坐标点
let aaef3 = new Vec3()
this.node.getWorldPosition(aaef3)
//在节点位置发射一条射线
const worldRay = new geometry.Ray(aaef3.x,aaef3.y,aaef3.z,0,1,0)
const mask = 0xffffffff
const maxDistance = 10000000
const queryTrigger = true
//检测多个物体
const bResult = PhysicsSystem.instance.raycast(worldRay,mask,maxDistance,queryTrigger)
if(bResult){
const results = PhysicsSystem.instance.raycastResults
for(let i = 0; i < results.length; i++){
const result = results[i]
const collider = result.collider
const distance = result.distance
const hitPoint = result.hitPoint
const hitNormal = result.hitNormal
console.log(distance + "aaaaaa")
}
}
}
update(deltaTime: number) {
}
}