what are the main differences between transform and Transform?

This is directly copied from the Unity reference guide on the topic of accessing objects through various ways. In the code below, the script uses “transform” to find “Hand” and then move it along the y-axis. Why does the script use lower-case transform? From what I’d read, I understood that “transform” (lower-case) is a variable and “Transform” was a class.

//Find child “Hand” of obj to which script is attached

transform.Find(“Hand”).Translate(0,1,0);

transform is an instance of that class. So when your script says ‘transform’ it is referring to the specific component that belongs to the game object the script is attached to.

And that’s exactly the answer to your question, though personally I’d say “object” rather than “variable”.

In short, “Transform” is a set of instructions which can be used to get a computer to store data and perform actions. ‘transform’ is a place in memory where those instructions have been applied.

The longer version…

“Transform” is a class or type. It’s a blueprint for the computer to create and work with a set of data and behaviour that represents something - in this case an object’s position, orientation and scale within a scene. Since it is a blueprint, it doesn’t store or do anything itself. It is simply a set of instructions that tell the computer how to store some data and/or do something meaningful. You can look at Transform and see that it describes how a position should be recorded, but it does not itself record a position.

“transform” is a reference to an object, a so-called “instance” of the above described class, where the computer has applied the blueprint to a chunk of its memory in order to store some data and/or do something meaningful. That chunk of memory now stores some data and some behaviour* (functionality) which can actually be used. You can look at transform and see a recorded position, assuming that you (via your computer) look at it as described by Transform.

Think of the difference between a recipe and a cake. You can read a recipe and see how to make a cake, but you need to follow the recipe to make an actual cake before you can eat it.

  • This isn’t strictly true, but it’ll do for the sake of explaining the concept.
1 Like