Why is the 'parent' property on transform and not gameObject?
As I see it, a gameObject contains components.
Transform is a component of a single gameObject, so in my way of thinking the parent of transform would be the gameObject, and not the parent of the whole element. So why is this?
Answer by Owen-Reynolds · Jul 05, 2018 at 10:59 PM
I think 2 style reasons. One is that 3D modeling programs use a Transform for parent/child. Unity tries to be friendly to experienced game designers.
The other, related, is that parent/child is mostly about the things a Transform holds (this may be what dan_wipf is getting at). When you change position/scale/rotation in a Transform, you run through it's child Transforms and update their stats. It's all Transforms -- you never touch a gameObject. And it's just as easy to walk through a tree of Transforms as one of gameObjects. It feels a little weird to walk from sub-object to sub-object, but it works fine. Esp. for people who prefer using: public Transform cow; as the primary way to link to gameObjects.
Answer by dan_wipf · Jul 05, 2018 at 09:32 PM
Well Unity Docs says to Transform:
Every object in a scene has a Transform. It's used to store and manipulate the position, rotation and scale of the object. Every Transform can have a parent, which allows you to apply position, rotation and scale hierarchically. This is the hierarchy seen in the Hierarchy pane.
as for GameObject it Says:
Base class for all entities in Unity scenes.
So in the end I'd say the difference is a GameObject can be anything. Like A Transform, a Script, or something else, which a Transform can't be. So the Parent is quite strongly connected with coordinates and size and stuff, which makes quite Sense to me that parenting is not on a "GameObject" rather on "Transform";
hope this helped. Dan
So you'd say it's sort of the other way round? The transform is the base and it can contain other gameObjects?
I guess for me it's just confusing because you always reference the gameObject as the thing you're trying to manipulate, like gameObject.transform.position.x
. When you right click and click "Create Empty", the new name is always gameObject in the hierarchy and not transform
That's why I see the gameObject as the "base element" and transform as a part of that gameObject
well ges, you’re right as well, but if you create an empty Gameobject, it has always an transform in it.. so think as gameobject as a container which holds all together, or a unique id which walks hand in hand with a transform
Answer by Perfecter · Jul 05, 2018 at 09:28 PM
I think "parent" and "child" are terms that can be only applied for transforms: for calculating local variables, for properly scaling, etc. GameObject is just, just like you said, container for other components, thats it.
Your answer
![](https://koobas.hobune.stream/wayback/20220612170121im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to rotate object based on four vector3 points? 0 Answers
Stereo Sounds In 3D Space 1 Answer
Instantiate Method won't work a second time. 0 Answers