Destroying targets

I don't think I'm understanding something correctly–that or either I'm encountering a bug. :slight_smile:

I'm implementing target destruction in my Asteroids-like shooter. It uses standard nodes with physics/sounds attached as children. When I destroy a game entity, I thought that all I'd need to do is detach it from the root node and, without any connection, the item would vanish.

When I shoot asteroids they disappear from the screen. Their sound and physics nodes persist, however, as illustrated by me still hearing them and the sounds they make when colliding with things.

So what am I missing? Should there be more to removing a game entity than detaching its parent node, or should this remove the child physics/sound nodes as well? Is it my responsibility to iterate through all the children and detach them from their parents, or is there some other mechanism?

You have to deactivate the physics node. Not sure what's needed for the sound stuff.

irrisor said:

You have to deactivate the physics node. Not sure what's needed for the sound stuff.

Ah, so detaching a node isn't necessarily supposed to remove all child nodes from the scene as well?

I ask because my sound implementation is based on the SoundNode classes posted last May, and I'm trying to make those behave as intuitively as possible, so I wasn't sure if they were supposed to stop playing when their parent nodes were detached, or if I should expect the user to keep track of/clean them up.

If you remove a Node from it's parent Node, all the childeren are also no longer in the scenegraph. However, if they're referenced externally (like I guess physics does?) and not through the update mechanism of the scenegraph that doesn't make a difference for those things.


but that sucks!  :-o

It is neccessary. Otherwise you won't be able to use physics objects with multiple scenegraphs ot without a scenegraph. Same goes for sound, I guess.