child entity problem, need help

Blitz3D Forums/Blitz3D Programming/child entity problem, need help

Mook(Posted 2004) [#1]
Ok, im trying to spawn a particle at a child objects cords....but the parent object is moveing, and the spawned particles are not, i have tried to use loadanimmesh to retain the cubes that i added, and i renamed them even, but problem is almost like the child entity is not moving with the parent entity

Quick example of what i would like to do is this

mdl=loadanimmesh("mdlname.3ds")

repeat
if keyhit(1) then end

moveentity mdl,1,0,0

create_engine_particle(mdl,"engspawn1")
forever

function create_particle(parent_entity, child_entity_name$)
engspawnref=findchild(parent_entity,child_entity_name$)
x#=entityx(engspawnref)
y#=entityy(engspawnref) etc..

engpart=createsprite()
positionentity engpart,x#,y#,z#
end function

Please help me someone im gonna go crazy :(


martonic(Posted 2004) [#2]
Use windowed, debug mode and put in

DebugLog "create_particle: " + str(engspawnref) + " " + str(x) + " " + str(y) + " " + str(z)

(just before "end function") and see what you're getting. Track the position of mdl the same way. Use that information to figure out your typo or whatever is causing the problem.


Mook(Posted 2004) [#3]
Ok, found what the problem was.....

b4 was
1) move parent
2) look at child cords and spawn the particle
3) particle not where its supposed to be :(

now working
1) move parent
2) detach child
3) spawn particle
4) reattach child
5) particle where it needs to be :)

for some reason blitz isn't updateing cordinates for entitys that have parents that have moved......workaround was to temporaley remove the entity from the parent..... then put it back when you get done getting the info you need from it.


Damien Sturdy(Posted 2004) [#4]
check the global parameters of your commands ;)


Mook(Posted 2004) [#5]
Ok, here is a very basic example of what the problem is, run once with comments, and once without, and then see if you can tell me where the problem is? i know it works with the lines uncommented......just letting others see if they see a variable thats not "global" or "debugged".......not trying to tick anyone off with this, cause i understand you are trying to help, but in this example it is not working the way it should.




big10p(Posted 2004) [#6]
As Cygnus mentioned, you can use a parameter with EntityX() etc. so that it returns the global, world coords of the entity:

EntityX(scube,1)

Whereas:

EntityX(scube)

returns the the Entity's position *relative* to it's parent.