|
|
@@ -1,4 +1,4 @@
|
|
|
-import { _decorator, Component, Node, Vec3, find, UITransform } from 'cc';
|
|
|
+import { _decorator, Component, Node, Vec3, Vec2, find, UITransform, RigidBody2D } from 'cc';
|
|
|
import { BulletTrajectory } from './BulletTrajectory';
|
|
|
const { ccclass, property } = _decorator;
|
|
|
|
|
|
@@ -167,10 +167,23 @@ export class BulletLifecycle extends Component {
|
|
|
return true;
|
|
|
} else {
|
|
|
console.log('💥 ground_impact 命中非地面,准备销毁');
|
|
|
- // 延迟销毁,确保爆炸延迟(如0.1s)能正常触发
|
|
|
+ // 延迟销毁,确保爆炸的 0.1 s 延迟能正常触发
|
|
|
this.scheduleOnce(() => {
|
|
|
this.state.shouldDestroy = true;
|
|
|
}, 0.2);
|
|
|
+
|
|
|
+ // === 立即冻结子弹运动,避免命中后继续绕圈 ===
|
|
|
+ const trajectory = this.getComponent(BulletTrajectory);
|
|
|
+ if (trajectory) {
|
|
|
+ trajectory.enabled = false; // 停止后续 update
|
|
|
+ }
|
|
|
+
|
|
|
+ const rigidBody = this.getComponent(RigidBody2D);
|
|
|
+ if (rigidBody) {
|
|
|
+ rigidBody.linearVelocity = new Vec2(0, 0);
|
|
|
+ rigidBody.angularVelocity = 0;
|
|
|
+ }
|
|
|
+
|
|
|
return true;
|
|
|
}
|
|
|
}
|