Home Game Development You are attempting to destroy a object twice or extra – Cocos Creator

You are attempting to destroy a object twice or extra – Cocos Creator

0
You are attempting to destroy a object twice or extra – Cocos Creator

[ad_1]

Hi, I’m attempting to destroy a node in Contact2DType.BEGIN_CONTACTcallback 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 sure, however nothing modifications.

If I wait fo the following 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 related points through the years with for instance destroy() and instantiate(), they’re synchronous features, however isn’t generated or destroyed utterly synchronously, so it’s important to mess around with setTimeout() generally to make sure you don’t crash your software program. This happes totally on larger scenes/prefabs and/or slower units.

A couple of years again I made a difficulty about this on Cocos github, my instance wasn’t the very best, since it’s onerous to copy on a contemporary small sport and the ticket bought closed .

thanks, it’s not an enormous situation to maneuver onto the following occasion loop however what’s unusual is that I can not see others having this situation right here within the discussion board. Anyway this thread incorporates a potential repair and an evidence, it’s superb to me.

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here