|
@@ -60,11 +60,28 @@ export class TornadoComponent extends Component {
|
|
this.tigger = this.tornado.getComponent(BoxCollider)!;
|
|
this.tigger = this.tornado.getComponent(BoxCollider)!;
|
|
this.radiusTigger = this.node.getChildByName('radiusTigger').getComponent(CylinderCollider)!;
|
|
this.radiusTigger = this.node.getChildByName('radiusTigger').getComponent(CylinderCollider)!;
|
|
|
|
|
|
|
|
+ // 初始化刚体设置
|
|
|
|
+ this.initializeRigidBody();
|
|
|
|
+
|
|
this.tigger.on('onTriggerEnter', this.onTriggerEnter, this);
|
|
this.tigger.on('onTriggerEnter', this.onTriggerEnter, this);
|
|
this.tigger.on('onTriggerStay', this.onTriggerStay, this);
|
|
this.tigger.on('onTriggerStay', this.onTriggerStay, this);
|
|
this.tigger.on('onTriggerExit', this.onTriggerExit, this);
|
|
this.tigger.on('onTriggerExit', this.onTriggerExit, this);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private initializeRigidBody(): void {
|
|
|
|
+ if (!this.rigidBody) return;
|
|
|
|
+
|
|
|
|
+ // 启用连续碰撞检测
|
|
|
|
+ this.rigidBody.useCCD = true;
|
|
|
|
+ // 设置合适的物理参数
|
|
|
|
+ this.rigidBody.allowSleep = false; // 防止刚体休眠
|
|
|
|
+ // 确保刚体能够正确进行碰撞检测
|
|
|
|
+ this.rigidBody.isKinematic = false;
|
|
|
|
+ this.rigidBody.useGravity = false;
|
|
|
|
+ // 设置较低的线性阻尼以确保平滑移动
|
|
|
|
+ this.rigidBody.linearDamping = 0.1;
|
|
|
|
+ }
|
|
|
|
+
|
|
protected initPlayer() {
|
|
protected initPlayer() {
|
|
this.attributeBonusMgr = AttributeBonusMgr.inst;
|
|
this.attributeBonusMgr = AttributeBonusMgr.inst;
|
|
const userModel = this.attributeBonusMgr.userModel;
|
|
const userModel = this.attributeBonusMgr.userModel;
|
|
@@ -77,7 +94,7 @@ export class TornadoComponent extends Component {
|
|
this.nickName = userModel.nickName;
|
|
this.nickName = userModel.nickName;
|
|
this.height = userModel.game_tornado_base_height;
|
|
this.height = userModel.game_tornado_base_height;
|
|
this.speed = Math.round((this.speed / 2) * 100) / 100;
|
|
this.speed = Math.round((this.speed / 2) * 100) / 100;
|
|
- this.speed = this.speed * 1.2;//测试
|
|
|
|
|
|
+ // this.speed = this.speed * 1.5;//测试
|
|
|
|
|
|
console.log(`玩家的速度:${this.speed}`);
|
|
console.log(`玩家的速度:${this.speed}`);
|
|
this.playerInfo = {
|
|
this.playerInfo = {
|
|
@@ -200,18 +217,23 @@ export class TornadoComponent extends Component {
|
|
|
|
|
|
if (event.selfCollider.node.name == 'RigibodyStorm') {
|
|
if (event.selfCollider.node.name == 'RigibodyStorm') {
|
|
if (event.otherCollider.node.name == 'RigibodyStorm') {
|
|
if (event.otherCollider.node.name == 'RigibodyStorm') {
|
|
- console.log('碰撞到其他龙卷风碰撞器!!!!');
|
|
|
|
const distance = Vec3.distance(event.selfCollider.node.worldPosition, otherCollider.node.worldPosition);
|
|
const distance = Vec3.distance(event.selfCollider.node.worldPosition, otherCollider.node.worldPosition);
|
|
- // console.log(`龙卷风之间 distance:${distance}`);
|
|
|
|
- if (distance <= 2) {
|
|
|
|
- if (this.currentLv > targetTornado.currentLv) {
|
|
|
|
- // console.log(`玩家等级:${this.currentLv} 大于 targetTornado等级:${targetTornado.currentLv}`);
|
|
|
|
- StormSunderAudioMgr.playOneShot(StormSunderAudioMgr.getMusicIdName(5), 1.0);
|
|
|
|
- this.curHitObj = targetTornado.node;
|
|
|
|
- this.addExpByKill();
|
|
|
|
- this.killed(targetTornado.node);
|
|
|
|
-
|
|
|
|
- Effect2DUIMgr.inst.addPKInfo(this.nickName, targetTornado.nickName);
|
|
|
|
|
|
+
|
|
|
|
+ // 增加碰撞检测的容差范围
|
|
|
|
+ const collisionThreshold = 3; // 增加检测范围
|
|
|
|
+ if (distance <= collisionThreshold) {
|
|
|
|
+ // 添加额外的速度检查,确保不会因为速度太快而错过碰撞
|
|
|
|
+ const relativeSpeed = Math.abs(this.speed - targetTornado.speed);
|
|
|
|
+ const minSpeedThreshold = 5; // 最小速度阈值
|
|
|
|
+
|
|
|
|
+ if (relativeSpeed >= minSpeedThreshold || distance <= 1.5) { // 如果速度差够大或距离非常近
|
|
|
|
+ if (this.currentLv > targetTornado.currentLv) {
|
|
|
|
+ StormSunderAudioMgr.playOneShot(StormSunderAudioMgr.getMusicIdName(5), 1.0);
|
|
|
|
+ this.curHitObj = targetTornado.node;
|
|
|
|
+ this.addExpByKill();
|
|
|
|
+ this.killed(targetTornado.node);
|
|
|
|
+ Effect2DUIMgr.inst.addPKInfo(this.nickName, targetTornado.nickName);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|