How to destroy a HARFANG object from a scene?

Question:

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(...)) ?

Asked By: pyblek

||

Answers:

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()

Answered By: Hadrien Mov
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.