Transform(ers) rollout!

Zach Lo
2 min readApr 19, 2021
Photo by Amr Taha™ on Unsplash

Ok, you have your Git repository synced, Unity is set up just the way you like it, how do we get things moving? First we have to understand how objects move in Unity. If we look into Unity’s scripting API documents under “Transform” we find there are many properties and methods used for transforming. What we are looking for is a method that will allow us to move or translate our game objects. Among the methods we see one called “Translate” which looks like it will give us exactly what we want.

Now that we have our method, how do we use it? We need to access the transform component of our object. If we type “transform.Translate()” the tooltip pop up tells us this will move the transform in the direction and distance of translation and I can pass in a Vector 3 translation.

There are two ways we can write out our code and both will yield identical results. First, “transform.Translate(Vector3.right);” will make our game object move to the right, this is the Unity API’s shorthand, pretty neat. Second, “transform.Translate(new Vector3(1, 0, 0));” is the long form equivalent which tells our object to move on the x axis +1 meaning to the right performing the same action. With this line of code our game objects now have the power of movement.

--

--

Zach Lo

Unity Developer | Community Manager with a passion for tech and entertainment