diff --git a/assets/script/game/hero/HeroViewComp.ts b/assets/script/game/hero/HeroViewComp.ts index be32345f..bd3762b4 100644 --- a/assets/script/game/hero/HeroViewComp.ts +++ b/assets/script/game/hero/HeroViewComp.ts @@ -544,6 +544,15 @@ export class HeroViewComp extends CCComp { // 清理残留的定时器和缓动 this.unscheduleAllCallbacks(); Tween.stopAllByTarget(this.node); + // 清理挂在节点下未播完的特效子节点(冰冻/击晕/受击等), + // 防止对象池复用节点时把上一个单位的特效带到新单位身上。 + // 判定依据:特效由 spawnTimedFx/spawnAnimEndFx 实例化并挂 timedCom/oneCom, + // 预制体自带子节点(anm/top 等)无这两个组件,不受影响。 + for (const child of [...this.node.children]) { + if (child.getComponent(timedCom) || child.getComponent(oneCom)) { + child.destroy(); + } + } this.topBar.reset(); // 清理碰撞器事件监听