it seens that both of them works the same…
1 Answer
1There’s a pretty big difference, but for starters a “Transform” is a component attached to a GameObject. If you’re scripting, a Transform has x,y,z position values, rotation values, and scale values. These can be expressed in C# as:
gameObject.transform.position
gameObject.transform.rotation
gameObject.transform.localscale
Saying gameObject.transform means you’re accessing the transform component attached to a GameObject, which can be misleading when you create an “Empty” GameObject in your scene, and only see a transform.
Using GameObject (case-sensitive) in scripting gives you access to methods that allow you to do pretty much anything, but that’s outside the scope of your question.
True. In shorter terms, one can say that a GameObject is the base class for everything in your world, every object in your game. A Transform is what defines the object's location, rotation and scale. The two are mutually inclusive by their very nature. There can be no GameObject without a Transform, a vice versa.
– CHPedersen