I would like to know how to destroy an object from a HARFANG scene? I'm using the Python HG API
I tried calling hg.DestroyObject(Object)
and scene.DestroyObject(Object)
but both failled.
Should I call the method differently or is my object referenced incorrectly (the object was created with Object = hg.CreateObject(...)
) ?
CodePudding user response:
If you need to destroy what you call an "object" but is actually a node carrying an object component, you have to make your way back to the node.
By addressing only the object level you will destroy the component but the node will still be there...
What's happening here is that CreateObject
has returned a node that contains this:
-- node --
|
-- transform (component)
|
-- object (component)
...indeed, your confusion is understandable: what you call an "object" by its generic definition is actually an object geometry.
anways ...
to destroy your "object" (actually your node) you just have to call my_scene.DestroyNode(my_node)
followed by a my_scene.GarbageCollect()