← Back to list

Translate & Rotate — Unity

In the previous article, I wrote about Vector Maths, describing the differences and use cases between Vectors (Vector2, Vector3, Dot and…

Zac Bogner · 2025-11-17 00:19 · 1 claps · 1.9 min read
#translate #rotate #vector #unity #game-development
Open on Medium ↗
Wiki topics: RAG · RAG & Retrieval 📐 · Mathematics 🎮 · Gaming

Translate & Rotate — Unity

In the previous article, I wrote about Vector Maths, describing the differences and use cases between Vectors (Vector2, Vector3, Dot and Cross Products).

This article will focus on Translate and Rotate.

Using the Tank script from the previous example, I’ll create the logic for the Translate & Rotate (for movement and rotation values).

I’ll declare two new variables in the Tank script, one for movement and the other for rotation as float values.

I’ll begin with setting up the inputs for the controls. W will be forward, A will be for turning left, S will be for backwards, and D will be for turning right.

First, I’ll change the input mode from GetKeyDown to GetKey for continuous input.

W and S keys will be for movement, using the Translation method.

I’ll also need to inverse the Vector3, due to the transform of the object facing the opposite way.

Then I’ll assign the Vector3 direction to be forward, and multiply the movement variable and also multiply by the time step of delta time.

For the Rotation method, I’ll want to get the up vector that will rotate or turn the tank left and right on the up axis (y). And then I’ll also multiply it’s turn speed variable and also multiply the time step of delta time.

With the S and D keys, for the S key, Vector3.back is the same as using the coordinates (0,0,-1). With the D key, I’ll use Vector3.down to inverse the up vector to rotate or turn the opposite direction from the A key to turn right.

And here’s the tank motion in action.

And that’s all for Translate and Rotate in Unity.

Stay tuned for more.

Thanks,

Zac B.


메타데이터
post_id
e4ce783adbfa
slug
translate-rotate-unity-e4ce783adbfa
url
https://medium.com/@racerzstudios/translate-rotate-unity-e4ce783adbfa
canonical_url
https://medium.com/@racerzstudios/translate-rotate-unity-e4ce783adbfa
author_url
https://medium.com/@racerzstudios
status
ok
fetched_at
2026-07-15 07:46:41