I have set the parent of a HUD camera’s transform to be the transform of the object it’s ‘orbiting’. The trouble is, when I then set the position of the child transform, it is still being moved to ‘global’ coordinates.
I have tested this in the Unity editor, paused the game, and the HUD camera is, indeed, a child of the parent object (it is listed under that object’s hierarchy).
hudCamera.transform.parent = hudSelectedObject.transform;
hudCamera.transform.position = new Vector3(0, 0, -50); // this still moves the HUD camera to global position 0, 0, -50 - why?
The parent object position is not 0, 0, 0, so it’s not just that the child object position is set relative to 0, 0, 0.
So how do I set the position of the HUD camera so it is relative to the parent transform position?
Thanks.