Using transform instead of gameObject

Hi I used to output against the Debug.Logerror statement. Which did return the correct name. But I was wondering was there a specific reason why the gameObject was used?

Hi Paul,

In which context did we use transform? Theoretically, name could have been sufficient due to the inheritence from MonoBehaviour. It depends, though.

Hi Nina

On the Else block,

I used transform as my train of thought was that both scripts were attached to the same object so I could access the transform directly. Rather in my mind you use gameObject to find another script that is in the hierarchy but not attached to the current one. ( sorry if explaining badly)

Thank you. In this case, it does not matter what you use. and both refer to the name of the game object in the Unity editor.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms