fix(碰撞处理): 增加防御性检查并优化英雄死亡时的碰撞体处理
在SkillView中添加对目标实体是否存在的检查,避免访问已销毁实体 在HeroViewComp中死亡时禁用碰撞体,防止"尸体"参与后续碰撞
This commit is contained in:
@@ -375,6 +375,13 @@ export class HeroViewComp extends CCComp {
|
||||
this.debugWarn("[HeroViewComp] realDead called but model is null, skipping");
|
||||
return;
|
||||
}
|
||||
|
||||
// 🔥 方案B:治理性措施 - 在销毁实体前先禁用碰撞体,从源头减少"尸体"参与碰撞
|
||||
const collider = this.getComponent(Collider2D);
|
||||
if (collider) {
|
||||
collider.enabled = false;
|
||||
}
|
||||
|
||||
if(this.model.fac === FacSet.HERO){
|
||||
// 英雄死亡:延迟触发死亡事件
|
||||
oops.message.dispatchEvent(GameEvent.HeroDead, {
|
||||
|
||||
Reference in New Issue
Block a user