Game Development Community

best way for object to delete itself? (solved)

by Justin Mosiman · in Torque Game Builder · 06/17/2009 (2:27 am) · 0 replies

What is the best way for an object, who has been added to a scene graph, to delete itself (from source)?

I have tried the plain
delete this
but the game always crashes at getIsValid(void) within t2dBaseDatablock.h. I have also first removed it from the scene graph with
getSceneGraph()->removeFromScene(this);
But it crashes at the same point.

If I try a this->deleteObject() an assert fails saying
Quote:
SimObject::deleteObject: Object not registered.

So, how do you delete yourself?

Edit:
Well, that was simple. safeDelete() does the trick.