Help With Inverse Transform Points

Hello,

Thanks in advance. Having a bit of a rough one with good old Unity today. Basically I’m trying to create a scene in which game object A moves around game object B (the user controls B). I’ve got a script on A that gets the inverse transform point of B as it’s moving around.

Now what I want to do is create a duplicate set of both of these objects (C and D) and move them elsewhere in world space (position and rotation wise). I want to take the inverse transform vector (B’s position relative to A’s local position) and write a script that uses those values to move D around C relative to C’s position and rotation.

I originally thought I could simply get my rotated C’s position in world space and, for instance, add the A/B inverse transform point x value to find out where D’s x position should be at every update. But that is not working. Does anyone have an idea? Please let me know if this is unclear. Many thanks.

So, to get this straight: A orbits B. D orbits C. You want D’s relative position around C, to match A’s relative position around B?

So something like this (pseudocode):

Vector3 localA = B.InverseTransformPoint(A);
D.position = C.TransformPoint(localA);

Amazing! Thank you!!!