I have an empty game object that will store objects created at runtime. I’ve positioned this object at (-80, 0, 0). I then create another empty game object, and add it as a child of that container:
childObject.transform.parent = containerObject.transform;
However, when I run the project, childObject is at (80, 0, 0), so it appears in the center of the screen. If I change the container’s location to (50, 50, 50), the child’s position will be (-50, -50, -50). Even if I explicitly set the child’s position zero:
childObject.transform.position = Vector3.zero;
It still sends up whatever the inverse of the container is.
I just want the child object to be at (0, 0, 0), relative to the container object, so that I can move the container object and all of its children will go with it.
How can I get these child objects to stop negating their parent’s transform?