CopyEntity and children

Blitz3D Forums/Blitz3D Programming/CopyEntity and children

Ziltch(Posted 2004) [#1]
Has CopyEntity always copied the children of the entity?

Without knowing this I created a lot of duplicate entities that seemed to have the names of already freed entities.

Two days to track down this feature of the command , which is not mentioned in the manual :(

graphics3d 640,400

cam = CreateCamera()
positionentity cam,0,0,-15


type ents
  field piv,cube
end type

piv=createpivot()
nameentity piv,"pivot"
cube=createcube(piv)   ;parent cube to pivot
nameentity cube,"cube"
entitycolor cube,1,255,1

EntityPickMode cube,2,1
for count = 1 to 6
  NewEnt.ents = new ents
  NewEnt\piv=copyentity(piv)  ;<< only copy pivot
  nameentity NewEnt\piv,"pivot 2"
  positionentity NewEnt\piv,rnd(-10,10),rnd(-10,10),0
  debuglog "child "+getchild(newent\piv,1)
next

hideentity cube   ;<< Free cube
freeentity cube
hideentity piv
freeentity piv


repeat

    renderworld
    pickedent=camerapick(cam,mousex(),mousey())
    if pickedent > 0 then
      text 10,10,"Point to Entity to get name."
      text 10,70, "pickedent = " + pickedent + " name is "+ entityname(pickedent)
      debuglog "pickedent = " + pickedent + " name is "+ entityname(pickedent)
    end if
    flip

until getkey()



jfk EO-11110(Posted 2004) [#2]
I find this pretty obvious. As when you delete an entity that has children, the kids get erased too. If you once had a MAV due to some missing children and then learned to unparent everything from an entity before deleting it if you sill need the children for other purposes (eg. recycled decals), you should know that parents have to be handled with care. Anyway, I aree, 2 days hurts.