How to tell if an object has been destroyed?


16-11-2009 08:50:24


I have an effects system - for explosions - the class will run and update for a few seconds then destroy the associated particle systems, and scene node.

Separately, my audio system updates 3d sounds' positions in space by calling SceneNode._getDerivedPosition() since all sounds are associated with a scenenode.

However sometimes the scenenode has been destroyed and _getDerivedPosition throws a nullreferenceexception (of course).

Is there any way to tell whether the object has been destroyed/disposed?



16-11-2009 10:06:31

Set all references to the SceneNode to null when you destroy it (ie inform your audio system that it has been destroyed) and check whether it's null when you use it.

Or check whether SceneNode.NativePtr is null.