the Addchild function

Started by kefeihappy, April 16, 2014, 06:00:00 AM

Previous topic - Next topic

kefeihappy

hello  sir 
  I'm  working  an Android  Game  about car!,
I have a group of objects (example, it is a car and its 4 wheels).
car.addchild(wheel1);
car.addchild(wheel2);
car.addchild(wheel3);
car.addchild(wheel4);
There is a special needs,
in game ,I  want to translate car,(not include wheels),  But a moving car and wheels, if I  translate wheels,  It's  work well(not include car),
there  are  some solutations can   do ?
Thanks you!(Please forgive my English is not very good, I'm from China)

EgonOlsen

Either don't make the wheels children of the car and adjust their transformations in your own code or compensate for the car's movement. The easiest way that doesn't interfere with the wheels' own translation might be to do this by using Object3D.setOrigin(...). So if you are moving the car x units up, move the wheels x units down. You can use translate as well for this, but that requires some more delta calculations and might be prone to rounding errors. setOrigin() might work better here.

kefeihappy

 Thanks sir, I will do it  like this  !