I’ve been having a lot of trouble trying to understand this or find some good documentation for it (probably because I am having trouble asking the right questions) but my first question is the one stated in the title.
For example, I have a prefab, and that prefab consists of two GameObjects… one parent and one child.
Now when I am coding a script on the child element (of the prefab mentioned above) I got to the point where I needed to look at the Network View component on the parent GameObject. Perhaps what I was trying to do with the NetworkView is incorrect but I am just experimenting and learning… however before I could even get that far I first needed to get the parent GameObject before accessing its components.
I figured that would be easy enough and that there would be a parent GameObject associated to each GameObject which I could access, but after spending quite a while looking around, I found out that I need to get the parent through the transform. That is very strange to me. In my mind the transform just has some physical traits of the object like position and rotation, so why would I have to ask it about who the parent is. It feels like the transform has data that makes sense to associate with the GameObject. To me that doesn’t make sense, so if someone could clarify why it is like that I would appreciate it.
It has been causing me problems with getting the actual parent, and if you’d like to help me out even more than explaining the above, it would be great to figure out how to actually get the parent GameObject. I did transform.parent.gameObject (in the script which is on the child object) but it ends up returning a transform instead of a GameObject which confuses me further. transform.parent and transform.parent.gameObject both seem to return transforms, when I would expect the second to return the GameObject.
I must be missing some very obvious things because to me it seems like transforms are just used in place of GameObjects sometimes and they contain data that I would think the GameObject should have instead.
Sorry for the long question, and I’m sure this is very basic… but I am honestly having a lot of trouble looking this up and understanding it all.