ball rotates around another ball
Hi, I created sphere 1 and 2, and sphere 2 is sphere1's child. How do I write my script to make sphere 1 rotates in place and sphere2(the child) rotates around it's parent? Just like a moon and an earth? thanks
Comment
Best Answer
Answer by Wrymnn · Feb 08, 2016 at 09:36 AM
Hey,
you can rotate the Sphere 1 with:
transform.Rotate();
But the Sphere 2, should not be parented directly to Sphere 1.
Create another empty object, call it Shpere_2_Pivot.
Parent this object to Sphere 1
Parent Sphere 2 to Shpere_2_Pivot
position Shpere_2_Pivot to (0, 0, 0)
position Sphere 2 as you desire (as a Moon relative to Earth)
Now, rotate the Shpere_2_Pivot object, set its speed etc. This should look like Moon and Earth rotation