box2d引擎报错问题

我做的项目是会有不断的生成预制(有RigidBody和BoxCollider),在运动到终点时再回收到Pool中,有概率报如下错误laya.physics.js:430 Uncaught TypeError: Cannot read property 'GetType' of null
    at box2d.b2Fixture.GetType (laya.physics.js:430)
    at box2d.b2ContactFactory.Create (laya.physics.js:576)
    at box2d.b2ContactManager.AddPair (laya.physics.js:586)
    at box2d.b2BroadPhase.UpdatePairs (laya.physics.js:308)
    at box2d.b2ContactManager.FindNewContacts (laya.physics.js:584)
    at box2d.b2World.Solve (laya.physics.js:799)
    at box2d.b2World.Step (laya.physics.js:811)
    at Physics._update (laya.physics.js:2003)
    at TimerHandler.run (laya.core.js:21423)
    at Timer._update (laya.core.js:21262)
 
相关逻辑代码如下:
    moveSuccess(){
this.owner.removeSelf();
Laya.Pool.recover("flyCat", this.owner)
}
onTriggerEnter(other: any, self: any, contact: any): void {
if (other.label === "cloud") {
Laya.Tween.clearAll(this._sp)
let effect: Laya.Animation = Laya.Pool.getItemByCreateFun("deathEffect", this.createEffect, this);
effect.pos(this._sp.x, this._sp.y);
this._sp.parent.addChild(effect);
effect.play(0, false);
this.owner.removeSelf();
Laya.Pool.recover("flyCat", this.owner)
}
}

createEffect(): Laya.Animation {
let ani: Laya.Animation = new Laya.Animation();
ani.loadAnimation("catFly.ani");
ani.on(Laya.Event.COMPLETE, null, recover);
function recover(): void {
ani.removeSelf();
Laya.Pool.recover("deathEffect", ani);
}
return ani;
}
error.png
已邀请:

Laya_Aaron

赞同来自:

请上传可以复现问题的精简demo

要回复问题请先

商务合作
商务合作