Contents
How to set the position of the child transform?
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?
Can a parent be the transform of a child?
Give us your feedback. Take our survey and let us know. 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.
How to reference a child object in Unity?
— Child Object (Secondary Script?) A) Create a public variable in main script, and simply drag/drop the child onto it in the inspector when setting up the prefab. Instantiating the prefab will maintain this relationship. Then you can get the correct child simply by saying…
Can you rotate an arbitrary point around another arbitrary point?
You can easily rotate an arbitrary point around another arbitrary point with the following: When everything is set up in the parent/child fashion as I said above, you can easily create a generic script to handle the orbits. Then just drop that script onto the bodies you want to orbit their parents.
How to set child relative position to its parent?
Reparenting in code is equivalent to dragging in the hierarchy view in the editor, and setting localPosition is equivalent to editing the transform’s position field in the inspector. So you can try these operations out by hand and watch what happens as you do, then maybe you can figure out why it’s not doing what you want.
Is the HUD Camera a child of the parent object?
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.position = new Vector3 (0, 0, -50); // this still moves the HUD camera to global position 0, 0, -50 – why?