One object follows another in concentric circles

In C# and Unity 3D, how can I script a gameobject to follow another gameobject’s movements while keeping the distance between the two, in a manner like below:

Looking down from above


When Object A moves around center object, Object B follows in a bigger circle to maintain its distance with A: For instance, when Object A moves from A1 to A2, Object B moves from B1 to B2. A1B1 = A2B2 i.e. the distance between A and B never changes. Also the ‘relative rotation’ between object B and the center object doesn’t change (for example, if B is a camera, the center game object (albeit a different side of it) remains in the middle of B’s view.

And looking from the side:


When object A moves up and down (for instance, from A1 to A2), object B also follows (move from B1 to B2) to maintain its distance with A.

Note that I don’t need to script object A’s movement - it’s already been scripted - it moves based on player input. It’s how to make object B follow A in the manner described above that is giving me headaches.

I really appreciate your help!

Position B1 = Center + (Position A1 - Center * RadiusB / RadiusA)

1 Like

Thank you so much. Managed to make it work thanks to your help, just with one minor correction. It’s actually:

Position B1 = Center + ( (Position A1 - Center) * RadiusB / RadiusA)

Thank you once again!

1 Like