【3.8.4】node使用removeFromParent()报异常

求助跟为大神:
先说一下场景:
在画面中有个固定的盒子,发射第一个node过去的时候,使用tween做位置移动和变形,在物理系统感知到碰撞的时候,终止tween的动作,并粘附到盒子上。第二个node发生后粘附到第一个node上。

我实现的逻辑:
1、盒子是静态刚体;
2、被发射的node使用预制代码生成;
3、并且node上绑定物理组件检测碰撞;
4、考虑到粘附的node可以随盒子移动,所以在判断碰撞后,先使用removeFromParent(),后加到盒子下。

问题:
发射第一个node时,上面的逻辑执行正常。
发射第二个时,因为有第一个node挡在第二个node和盒子之间,所以物理碰撞时检测两个node是否有碰撞,碰撞检测有回调,但在执行第4个逻辑的时候,removeFromParent()过程报错。

异常提示信息:
[PreviewInEditor]

Error:

at b2Body.SetActive (C:\ProgramData\cocos\editors\Creator\3.8.4\resources\resources\3d\engine\node_modules@cocos\box2d\build\box2d\box2d.umd.js:7194:16)

at b2RigidBody2D.setActive (C:\ProgramData\cocos\editors\Creator\3.8.4\resources\resources\3d\engine\bin.cache\dev\editor\bundled\index.js:203963:22)

at b2RigidBody2D.onEnable (C:\ProgramData\cocos\editors\Creator\3.8.4\resources\resources\3d\engine\bin.cache\dev\editor\bundled\index.js:203831:16)

at RigidBody2D.onEnable (C:\ProgramData\cocos\editors\Creator\3.8.4\resources\resources\3d\engine\bin.cache\dev\editor\bundled\index.js:289826:24)

at eval (eval at tryCatchFunctor_EDITOR (C:\ProgramData\cocos\editors\Creator\3.8.4\resources\resources\3d\engine\bin.cache\dev\editor\bundled\index.js), :4:10)

at OneOffInvoker.eval [as _invoke] (C:\ProgramData\cocos\editors\Creator\3.8.4\resources\resources\3d\engine\bin.cache\dev\editor\bundled\index.js:40581:13)

at OneOffInvoker.invoke (C:\ProgramData\cocos\editors\Creator\3.8.4\resources\resources\3d\engine\bin.cache\dev\editor\bundled\index.js:40501:16)

at NodeActivator.activateNode (C:\ProgramData\cocos\editors\Creator\3.8.4\resources\resources\3d\engine\bin.cache\dev\editor\bundled\index.js:42519:29)

at Node._onHierarchyChangedBase (C:\ProgramData\cocos\editors\Creator\3.8.4\resources\resources\3d\engine\bin.cache\dev\editor\bundled\index.js:45158:46)

at Node._onHierarchyChanged (C:\ProgramData\cocos\editors\Creator\3.8.4\resources\resources\3d\engine\bin.cache\dev\editor\bundled\index.js:45600:16)

at Node.setParent (C:\ProgramData\cocos\editors\Creator\3.8.4\resources\resources\3d\engine\bin.cache\dev\editor\bundled\index.js:44314:16)

at Node.addChild (C:\ProgramData\cocos\editors\Creator\3.8.4\resources\resources\3d\engine\bin.cache\dev\editor\bundled\index.js:44395:17)

at LeftControl.moveWoodEnd (file:///D:/Cocos%20Project/RollCancellation/temp/programming/packer-driver/targets/editor/chunks/49/49ac90ba89e20f00c7c70cf656ad968eab3ebc65.js:164:30)

at LeftControl.onBeginContact (file:///D:/Cocos%20Project/RollCancellation/temp/programming/packer-driver/targets/editor/chunks/49/49ac90ba89e20f00c7c70cf656ad968eab3ebc65.js:191:22)

at BoxCollider2D.emit (C:\ProgramData\cocos\editors\Creator\3.8.4\resources\resources\3d\engine\bin.cache\dev\editor\bundled\index.js:137493:28)

at PhysicsContact.emit (C:\ProgramData\cocos\editors\Creator\3.8.4\resources\resources\3d\engine\bin.cache\dev\editor\bundled\index.js:203308:23)

at PhysicsContactListener._onBeginContact [as _BeginContact] (C:\ProgramData\cocos\editors\Creator\3.8.4\resources\resources\3d\engine\bin.cache\dev\editor\bundled\index.js:203715:13)

at PhysicsContactListener.BeginContact (C:\ProgramData\cocos\editors\Creator\3.8.4\resources\resources\3d\engine\bin.cache\dev\editor\bundled\index.js:286463:18)

at b2PolygonContact.SetEnabled [as Update] (C:\ProgramData\cocos\editors\Creator\3.8.4\resources\resources\3d\engine\node_modules@cocos\box2d\build\box2d\box2d.umd.js:11829:1)

at b2World.SolveTOI (C:\ProgramData\cocos\editors\Creator\3.8.4\resources\resources\3d\engine\node_modules@cocos\box2d\build\box2d\box2d.umd.js:20500:30)

at b2World.Step (C:\ProgramData\cocos\editors\Creator\3.8.4\resources\resources\3d\engine\node_modules@cocos\box2d\build\box2d\box2d.umd.js:19618:7)

at b2PhysicsWorld.step (C:\ProgramData\cocos\editors\Creator\3.8.4\resources\resources\3d\engine\bin.cache\dev\editor\bundled\index.js:203518:23)

at PhysicsSystem2D.postUpdate (C:\ProgramData\cocos\editors\Creator\3.8.4\resources\resources\3d\engine\bin.cache\dev\editor\bundled\index.js:206973:31)

at Director.tick (C:\ProgramData\cocos\editors\Creator\3.8.4\resources\resources\3d\engine\bin.cache\dev\editor\bundled\index.js:17666:34)

at Game._updateCallback (C:\ProgramData\cocos\editors\Creator\3.8.4\resources\resources\3d\engine\bin.cache\dev\editor\bundled\index.js:19321:22)

at updateCallback (C:\ProgramData\cocos\editors\Creator\3.8.4\resources\resources\3d\engine\bin.cache\dev\editor\bundled\index.js:78612:20)

at sentryWrapped (C:\ProgramData\cocos\editors\Creator\3.8.4\resources\app.asar\node_modules\src\helpers.ts:100:17)

没有人遇到过吗?我的理解是tween中的stop,没有完全终止,所以到导致removeFromParent()异常

物理同步好像是在lastUpdate 所以删除节点太早可能会儿引发错误 感觉是

感谢回复 :grinning: