Author Topic: the Addchild function  (Read 2087 times)

Offline kefeihappy

  • byte
  • *
  • Posts: 11
    • View Profile
the Addchild function
« on: April 16, 2014, 06:00:00 am »
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)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: the Addchild function
« Reply #1 on: April 16, 2014, 10:19:34 am »
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.

Offline kefeihappy

  • byte
  • *
  • Posts: 11
    • View Profile
Re: the Addchild function
« Reply #2 on: April 17, 2014, 03:38:02 am »
 Thanks sir, I will do it  like this  !