update(deltaTime: number) {
//更新子碰撞体的位置
this.ff4.setPosition(this.ff4.position)
this.ff3.setPosition(this.ff3.position)
this.ff2.setPosition(this.ff2.position)
this.ff1.setPosition(this.ff1.position)
this.ff5.setPosition(this.ff5.position)
this.ff6.setPosition(this.ff6.position)
this.ff7.setPosition(this.ff7.position)
this.ff8.setPosition(this.ff8.position)
this.ff9.setPosition(this.ff9.position)
this.ff10.setPosition(this.ff10.position)
this.ff11.setPosition(this.ff11.position)
this.ff12.setPosition(this.ff12.position)
//载具的移动
// 根据自身方向,转化方向
this.res1 = new Vec3(0, 0, this.sp2);
//获取节点的本地化局部旋转方向,1:返回值,2:需要转换的方向向量,3:当前本地旋转
Vec3.transformQuat(this.res1, this.res1, this.node.getWorldRotation());
this.node.getComponent(RigidBody).setLinearVelocity(v3(this.res1.x, this.sp1, this.res1.z))
this.node.getComponent(RigidBody).setAngularVelocity(v3(0,this.sp3,0))
}
update(deltaTime: number) {
// 根据自身方向,转化方向
this.res1 = new Vec3(this.x1 * this.sp1 * deltaTime, 0, this.z1 * this.sp1 * deltaTime);
//获取节点的本地化局部旋转方向,1:返回值,2:需要转换的方向向量,3:当前本地旋转
Vec3.transformQuat(this.res1, this.res1, this.node.getWorldRotation());
//移动方式的切换开关,获取组件开关,开启或关闭
//this.characterController.enabled = false
//this.node.getComponent(CapsuleCollider).enabled = true
//在载具外移动的方式
if(this.characterController.enabled && !this.node.getComponent(CapsuleCollider).enabled){
this.characterController.move(v3(this.res1.x, -0.2, this.res1.z));
}
//在载具内移动的方式
if(this.node.getComponent(CapsuleCollider).enabled && !this.characterController.enabled){
this.node.setPosition(this.node.position)
this.node.setWorldPosition(this.res1.x+this.node.worldPosition.x, this.node.worldPosition.y, this.res1.z+this.node.worldPosition.z)
}
}