Hello, I’m making an attempt to destroy a node in Contact2DType.BEGIN_CONTACT
callback however get
You are attempting to destroy a object twice or extra.
error.
I’m additionally checking for
if (this.node && this.node.isValid) this.node.destroy();
simply to make certain, however nothing modifications.
If I wait fo the subsequent loop it really works as anticipated
setTimeout(() => {
if (this.node && this.node.isValid) this.node.destroy();
}, 0)
Any recommendation ?
This error could be debugged right here to see the place it’s coming from.
I had comparable points through the years with for instance destroy() and instantiate(), they’re synchronous features, however isn’t generated or destroyed utterly synchronously, so you need to mess around with setTimeout() typically to make sure you don’t crash your software program. This happes totally on larger scenes/prefabs and/or slower units.
A number of years again I made a difficulty about this on Cocos github, my instance wasn’t one of the best, since it’s laborious to duplicate on a recent small recreation and the ticket acquired closed .
thanks, it’s not an enormous subject to maneuver onto the subsequent occasion loop however what’s unusual is that I can not see others having this subject right here within the discussion board. Anyway this thread comprises a potential repair and a proof, it’s fantastic to me.
Ive skilled the identical subject when making an attempt to destroy some nodes on onContactBegin. Let me strive utilizing a setTimeOut()