Saturday, October 29, 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 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 certain, however nothing adjustments.

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 may be debugged right here to see the place it’s coming from.

I had related points over time with for instance destroy() and instantiate(), they’re synchronous capabilities, however isn’t generated or destroyed fully synchronously, so you must 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 problem about this on Cocos github, my instance wasn’t one of the best, since it’s arduous to copy on a recent small recreation and the ticket bought closed .

thanks, it’s not an enormous challenge to maneuver onto the subsequent occasion loop however what’s unusual is that I can’t see others having this challenge right here within the discussion board. Anyway this thread accommodates a doable repair and a proof, it’s superb to me.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments