🎮 Unity C# Basics: Transform.rotation
(aka how to make things spin, turn, and look cooler than they should 🔄)

Alright, confession time, when I first tried to make something rotate in Unity, I legit thought it’d be like drag-and-drop easy. Nope. The cube just stared at me. Dead still. Like, “nah, I’m good.”
Then I discovered transform.rotation, and suddenly… spinning things was my new hobby 😎
🌀 So, What’s transform.rotation Anyway?
Basically, it controls which way your object is facing.
Move = transform.position
Rotate = transform.rotation
It’s like telling your GameObject,
“Hey, face that way now.”
Simple. Beautiful. Mildly addictive.
🧠 The Quick Example
Here’s your spin spell 🪄
void Update()
{
transform.Rotate(Vector3.up * 50f * Time.deltaTime);
}
That’s it.
Hit play → your cube goes wheeeeee 🌀
Each frame, you’re rotating around the Y-axis (up/down).
The Time.deltaTime just makes sure it spins smoothly and not at warp speed.
💡 Real Talk: Where You’ll Actually Use This
Rotating fans (every Unity dev has made one, don’t lie 😂)
Spinning coins or collectibles 💰
Smoothly turning players or cameras
A dramatic door open animation
Basically… anytime something needs to look alive.
⚙️ Bonus Trick: LookAt()
Feeling fancy? Try this:
void Update()
{
transform.LookAt(target);
}
Now your object will constantly turn to face something like an enemy tracking the player 👀
Creepy? Maybe. Cool? Absolutely.
🚀 Wrap Up
transform.rotation is small but powerful.
You’ll use it for spinning, aiming, or just adding life to stuff that feels stiff.
And trust me, once you get it, you’ll rotate everything.



