update(deltaTime: number) {
// 根据自身方向,转化方向
const res1 = new Vec3(this.pb1.x,0,-this.pb1.y);
//获取节点的本地化局部旋转方向,1:返回值,2:需要转换的方向向量,3:当前本地旋转
Vec3.transformQuat(res1, res1, this.node.getRotation());
//射线检测
let js1 = new geometry.Ray(this.node.worldPosition.x,this.node.worldPosition.y,this.node.worldPosition.z,res1.x,res1.y,res1.z)
if(PhysicsSystem.instance.raycastClosest(js1,this.mask,this.maxDistance,this.queryTrigger)){
const js2 = PhysicsSystem.instance.raycastClosestResult
const js3 = js2.distance
//最小距离3
if(js3<3){
this.ri1.setLinearVelocity(v3(0,0,0))
return
}
}
//动力学移动
if(this.pg1 && this.pg4){
this.ri1.setLinearVelocity(v3(res1.x*this.sp1,0,res1.z*this.sp1))
}
}