Transform
How to use the Transform component to Position, Rotate and Scale a GameObject!
The Transform Component determines the Position, Rotation, and Scale of each object in the scene. Every GameObject has a Transform.
It contains useful functions such as Rotate, LookAt and Translate. And also useful variables such as position, rotation and forward.
Examples
Shortcut variable
Because Transform is a common component, there is a shortcut property available to access it in any MonoBehaviour.
Transform.position
Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.
Submission failed
For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.
Description
The world space position of the Transform.
The position property of a GameObject’s Transform, which is accessible in the Unity Editor and through scripts. Alter this value to move a GameObject. Get this value to locate the GameObject in 3D world space.
The example gets the Input from Horizontal and Vertical axes, and moves the GameObject up/down or left/right by changing its position.
How do I find the location of a GameObject in C#
I’m making an elevator script. Essentially I’m wanting to find the difference between two empty objects so that I can move the elevator between them.
To be able to do this, I need to be able to get the location of both GameObjects in my script. From a bit of searching, I haven’t been able to figure it out.
How would I go about doing this?
![]()
2 Answers 2
Basically its all the game of terminologies, probably you couldn’t find anything because of it.
Actually the basic term is Transformation which includes three basic attributes of any object, i.e. Translation( position ), Rotation and Scaling.
Have a look in detail from these answers
Right terms are so important because of there generality.
For example lets take a term Gameloop that is a general term. So you can search it for any game engine through this term, but if you know only Unity’s Update method then it’d be much difficult for you find it for any other game engines. That is how the general terms work.
So your term location is not suitable though, you should use position instead when you are searching.
In Unity gameObject.transform.position will give you the global position of gameObject through its transform component.
I think that is the thing you want to know. Let me know if I did miss anything.
![]()
To get the position of a gameobject in the world, you can retrieve a Vector3 (x,y,z) of it’s Position from the Transform component that’s added by default to every gameobject, as seen in the inspector:

gameObject.Transform.position returns the absolute world position. Note that this is the same as GetComponent<Transform>().position on your gameobject.
gameObject.Transform.localPosition returns the position relative to that gameobject parent’s position — if your gameobject has a parent whose position is not 0,0,0 this will return the Vector3 value of what you see in the inspector, rather than the absolute world position.
If you’re not sure how to reference the two gameobjects in your script, the simplest and most basic way is to create two GameObject variables in your script and expose them in the editor (since they are serializable):
Above: Two ways of exposing a variable to the Unity Inspector

Above: The result, now you can simply drag and drop GameObjects into these slots.
Visual Scripting Components Part 1: Transform
In this article, we will get to know how we can move, rotate and scale Game Objects in Unity’s Visual Scripting. We’ll explore all the nodes Unity offers for working with the Transform component.
Properties
When working with Game Objects, we want to move and change them by accessing the Transform component’s properties.
Position
To access the position of a Game Object in the world, we use the Get Position node. To modify it, we’ll use the Set Position node.

Scale
We can use the Get Lossy Scale node to get the Object’s actual size.

Rotation
When we want to rotate an Object, we have the Get Euler Angles & Set Euler Angles nodes; we can retrieve and modify the Object’s rotation angle through them.

If we want to increase or decrease the existing rotation angle, we can use the Transform Rotate node. It also allows us to configure the Relative To option, which we can set to World or Self – determining whether to rotate the Object relative to itself or to the parent Game Object it is under.

Check out our high–quality Unity assets!
![]()
![]()
![]()
Parenting
When we nest Objects in the hierarchy, we refer to them as a parent and child.
We have access to various nodes dedicated to controlling the Objects’ hierarchy.
In some cases, we will set a Game Object as a child affected by its parent, such as the case of a tank’s turret. We want the turret to rotate and move along with the tank’s body, so we’ll set it as a child of the body Object.
In the graph, we use the Get Parent & Set Parent nodes to control the Object’s parent and retrieve it.
We got another node for setting the parent, Set Parent (World Position Stays) node, and with it, as its name suggests, we can choose to retain the Object’s world position, rotation, and scale when changing the parent.

A parent Object may have multiple children; we can ask for a specific child using the Get Child node or count them with the Get Child Count node.
Combing these nodes with the For Loop node, we access all the parent’s children.
The Detach Children node allows us to disconnect all the parent’s child Game Objects.

Local vs World
We already know we can get and set the different properties of the Transform component; we can also transform Game Objects relative to their parent.
We can use nodes similar to those we met earlier:
- Get/Set Local Position
- Get/Set Local Scale
- Get/Set Local Euler Angles
These nodes differ from the previous nodes we learned about in such they are retrieving or changing the properties based on the parent. For example, Get Local Position provides us the distance from the parent instead of the position in the world.

Outstanding Assets For Boosting Development
Moving Objects
Moving a Game Object is a fundamental part of creating any game in Unity, and as such, there are many ways to do so.
The Translate node moves a Game Object in the direction and distance based on the vector input. It’s a shortcut for a graph built of Get Position and Add nodes connected to Set Position.

Another valuable node is Look At. With this node, we can rotate to follow another Game Object as it moves.

For example, we can make the game’s camera follow another Game Object.
We add a Script Graph to the camera Game Object and connect the Update event to the Look At node. We attach the Game Object to the Target input using the Game Object Find node. When we move the Game Object at runtime, the camera will follow it around.
Movement Direction
We can get the direction axis the Transform faces with the Get Up, Get Right, and Get Forward nodes:
- Get Up is for the green arrow.
- Get Right is for the red arrow.
- Get Forward is for the blue arrow.

When it comes to controlling the movement direction of a Game Object, these nodes come in handy.
For example, connecting the Get Up node to the Translate node will move the Object one unit in the direction of the green arrow.