Entities parent

Blitz3D Forums/Blitz3D Programming/Entities parent

Is there a way to determine an entities parent? What I am doing is creating my own custom partical system, and I am attaching emitters to entities, but i need to know when the entity has been destroyed/freed so that the emitter can detroy itself at the time the parent is destroyed.

GetParent()

Cool, thanks. However if the parent has been removed then this command still causes the program to crash with entity does not exist.

Think I have a workaround though. I can make a global pivot called Trashcan, when say a rocket with an emiiter attached to it explodes, i can cycle through its children and reparent them to trashcan, now in the emitter loop if the parent is trashcan then delete the emitter properly.

If you know of a better way please let me know. Thanks

First - why don't you use the entity the emitter is attached to as the parent. Second just use getParent()

if getparent(particle)=0 freeentity particle


well it seems that if you set a parent to an entity, then free the parent.. Getparent will still report the same entity as the parent even though it does not exist anymore.

Example:

Graphics3D 640,480,16

CUBE1=CreateCube()
CUBE2=CreateCube()


While Not KeyDown(1)
If KeyHit(2) Then EntityParent CUBE1,CUBE2
If KeyHit(3) Then EntityParent CUBE1,0
If KeyHit(4) Then FreeEntity CUBE2
If KeyHit(5) Then CUBE2=CreateCube()

UpdateWorld()
RenderWorld()
Cls
Text 10,10,"CUBE1 PARENT "+ GetParent(CUBE1)
Text 10,60,"CUBE2 PARENT "+ GetParent(CUBE2)
Flip
Wend

Sorry, I didn't read the question properly.