Thursday, October 27, 2022
HomeGame DevelopmentYou are attempting to destroy a object twice or extra - Cocos...

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


Hello, I’m making an attempt 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 adjustments.

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 might 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 fully synchronously, so you need to mess around with setTimeout() generally to make sure you don’t crash your software program. This happes totally on greater scenes/prefabs and/or slower gadgets.

Just a few years again I made a difficulty about this on Cocos github, my instance wasn’t the most effective, since it’s onerous to copy on a contemporary small sport and the ticket acquired closed .

thanks, it’s not a giant subject to maneuver onto the following 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 incorporates a doable repair and an evidence, it’s advantageous to me.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments