[SOLVED] JS code: best way to destroy an instance?

Is the best way to destroy an instance of an object created in a JS code block to use;

object.deleteFromScene(runtimeScene);

This appears to work, it’s just the editor calls this process “destroy” and yet this function is called “deleteFromScene”, so I was wondering if this is the correct way to destroy it entirely (and all references to it) so that it may be ‘garbage collected’ and free up any memory used for it ?

deleteFromScene will remove and destroy the object from the scene in the sense that it will trigger any required unload and the object will be garbaged collected :slight_smile: (actually it’s put in a “pool” to be reused and avoid putting too much pressure on the GC in case you’re destroying and re-creating a lot of these objects, like bullets).
On your side, you just have to be sure not to keep any reference to the object once you called deleteFromScene (consider the object as gone)

1 Like

Thank you! :slight_smile: