I have made a game where I make two spheres, one child sphere and one parent sphere. The parent sphere is bigger than the child sphere, and I am trying to make the child move around the parent sphere.
In the following code, the child sphere moves in a circle. The problem is that it does not move in relation to the parent, so whenever I move the parent of the object, the child stays and no longer moves around the parent, but rather moves freely. I accept that this is a lot to ask, but if someone could contribute, it would be greatly appreciated. Here is the code I have which moves the sphere (not in relation to the parent object):
void Update(){
timeCounter += Input.GetAxis("Horizontal") * Time.deltaTime;
float x = Mathf.Cos (timeCounter);
float y = Mathf.Sin (timeCounter);
float z = 0;
transform.position = new Vector3 (x, y, z);
}
I also intend to move the parent sphere and I expect the child sphere to follow and still move in relation to the parent sphere.
Thats because you are moving the sphere via
when it should be
Either that or you could do
EDIT: personally, i would do the latter and not even parent the sphere, that way you can rotate the mother sphere or manipulate it independantly without effecting the other sphere in weird ways