www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: kefeihappy on April 16, 2014, 06:00:00 am

Title: the Addchild function
Post by: kefeihappy 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)
Title: Re: the Addchild function
Post by: EgonOlsen 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.
Title: Re: the Addchild function
Post by: kefeihappy on April 17, 2014, 03:38:02 am
 Thanks sir, I will do it  like this  !