fix(skill): 延迟销毁技能实体以避免物理回调中直接销毁刚体

修复在物理回调中直接销毁刚体可能导致的问题,改为使用scheduleOnce延迟到下一帧销毁
This commit is contained in:
walkpan
2026-01-06 14:48:42 +08:00
parent 974a6d26b2
commit 47575ca0b8

View File

@@ -177,7 +177,12 @@ export class SkillView extends CCComp {
(this.SConf.EType != EType.animationEnd) &&
(this.SConf.EType != EType.timeEnd)
) {
this.ent.destroy(); // 技能命中次数达到上限后销毁
// 修复:物理回调中不能直接销毁刚体,需延迟到下一帧
this.scheduleOnce(() => {
if (this.ent) {
this.ent.destroy();
}
}, 0);
}
}
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */