Moon rotation problem.

Hello.
So I have this problem with my moons rotation. This is the script (It’s attached to the planets):

float Distance = transform.localScale.x + Random.Range(10,20);
		
Instantiate(Moon,new Vector3(transform.position.x + Distance,0,transform.position.z), Quaternion.Euler(0,0,0));

(in Update)

Moon.transform.RotateAround(transform.position, Vector3.up, 0.7f * Time.deltaTime);

The problem is, that moons get placed but they don’t rotate around planets.

I was thinking about attaching the rotation code to the Moon prefab, but I’m not sure how would this work.

-Xentarok

P.S - Forgive me any language mistakes.

You want to rotate the thing you instantiated, not the general prefab you have declared.

float Distance = transform.localScale.x + Random.Range(10,20);
GameObject myMoon;
 
myMoon = (GameObject) Instantiate(Moon,new Vector3(transform.position.x + Distance,0,transform.position.z), Quaternion.Euler(0,0,0));
 
(in Update)
 
myMoon.transform.RotateAround(transform.position, Vector3.up, 0.7f * Time.deltaTime);

Turn myMoon into an array or list, and properly fill it up with instantiated moons, and you can make a cycle that rotates all of them, so you would have more than 1 moon per planet.

French Open Live Stream

French Open 2014 Live Stream