- Home /
Difference between Transform vs transform
I am currently watching some video tutorials and i saw the example below (looping through childrens):
for (var children : Transform in transform) {
...
}
Whats the difference between Transform and transform ? What does transform contain and it is used to loop inside it? Is it some kind of an array?
Also is it valid to do the same thing with the code below??:
for (var children : GameObject in gameObject) {
...
}
Thanks
Answer by whydoidoit · May 07, 2013 at 06:41 PM
Transform is the name of the class that contains the information about a transform. transform is a property of an object that gives you the instance of the Transform for that object. So your for loop defines a looping variable called children (it should really be child) that is going to be a Transform so you get the instance for each child.
Transform itself defines that it can have a for loop run against it and that it will return its children when you do that. The same is not true for GameObject. So to get the children you have to use the transform variable in the for loop. This is because the relationships between objects are defined by transform.parent.
Answer by Fred_Vicentin · May 07, 2013 at 06:49 PM
Transform is used to store and manipulate the position, rotation and scale of the objects, you can declare a Transform and drag a object to it, to get it Transform and change it Transform, for example, a Empty GameObject has nothing on it, but you can use it as a Transform to set a Spawn Position to the Player, for example:
var spawn: Transform;
function Update ()
{
//That will make you object, go to Spawn position
transform.position = Spawn.position;
}
Every Object on Unity has a transform, that is represented with the cordinates and rotation value on map
When you call a transform, you are calling the value of the Transform, you can use a transform.position, or a transform.rotation for example, to get the coordinates of the gameObject, for more informations, you can access the Unity documentation that has more informations of Transform here
Answer by himanshugupta159 · Jul 20, 2018 at 08:34 AM
Written a blog related to it, check the link belowlink text
Your answer
![](https://koobas.hobune.stream/wayback/20220613101754im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
What's the difference between gameObject and transform when using GetComponent 2 Answers
Pitch/yaw difference between 2 transforms 1 Answer
Difference Between Transform.TransformVector and Transform.TransformPoint 1 Answer
Unity Car Accelerometer 0 Answers
using MoveObject to perform 2 translations at the same time 1 Answer