Component's transform

I’m very new to Unity3D and trying to figure out one thing: all the components are descendants of Component, so they all have attribute named transform. So imagine we have some game object with attached rigid body. So what is the difference between

myGameObject.transform

myGameObject.rigidbody.transform

myGameObject.renderer.transform

myGameObject.animation.transform

and all other components ?

well, you use the dots to “step through” the hierarchy of components. There is only one transform, but depending on where you start you may have to take a different path to reach it.For example:

var myGameObject: GameObject; //this var represents a GameObject

myGameObject.transform … to access transform

myGameObject.transform.position.y … the y component, of the position component, of the transform

var myOtherObject : Rigidbody; … // references the game object via it’s Rigidbody

myOtherObject.gameObject.transform … // takes an extra step

each step through the hierarchy must be accounted for, so

myOtherObject.transform

wouldn’t do it

but you wouldn’t see the examples you suggested:

animation.transform
renderer.transform

because these are two unrelated components, you don’t need to step through animation to reach transform, and since “animation” does not have a component called “transform”, this would not work

Rather, I might say something like :

myGameObject.renderer.enabled = true;

or

myOtherObject.gameObject.animation.Play();

note:
lower-case keywords like those above (renderer, gameObject, animation, transform) are a keyword shortcut to the corresponding component on the object containing the script, for example:

transform references the Transform component on this object,

etc