Goal
This lesson teaches the smallest useful Unity scripting loop: attach a component, update every frame, and see a visible 3D result immediately.

Create your first C# script and spin a 3D object smoothly with Update and Time.deltaTime.
Lesson Overview
This lesson teaches the smallest useful Unity scripting loop: attach a component, update every frame, and see a visible 3D result immediately.
15-20 min / Beginner. Keep the first pass small, then change one thing on your own.
The object rotates as soon as Play starts.
Before You Start
The lesson is easiest to follow when you know what should happen on screen, which control or editor action triggers it, and what counts as done.
This lesson teaches the smallest useful Unity scripting loop: attach a component, update every frame, and see a visible 3D result immediately.
Understand the role of a MonoBehaviour script attached to a scene object.
The object rotates as soon as Play starts.
If you are completely new to Unity scripting, rotating a cube is one of the best first exercises because it links code to a visible result in seconds. You do not have to understand every Unity system at once. What matters is learning the small loop of 'write code, attach the script, press Play, observe the result, and adjust a value.'
This lesson is intentionally simple, but the pattern behind it appears everywhere in game development. Once you understand how Update runs, how serialized fields appear in the Inspector, and why Time.deltaTime matters, you have the foundation needed for movement, animation helpers, camera behavior, and many other gameplay scripts.
using UnityEngine;
public class RotateObject : MonoBehaviour
{
[SerializeField] private Vector3 axis = new Vector3(0f, 1f, 0f);
[SerializeField] private float speed = 90f;
private void Update()
{
transform.Rotate(axis * speed * Time.deltaTime);
}
}This usually means the script was created but never attached to the Cube, or the Console shows a compile error in another script. In Unity, one broken script can stop all scripts from compiling, so always check the Console when something feels strangely inactive.
Beginners often forget that 90 means 90 degrees every second, not every frame. If the result feels extreme, lower the speed value first before changing the axis or rewriting the logic.
A local object's orientation may already be turned in the scene, so rotating around Y might not visually match your expectation. Try one axis at a time and remember that local orientation affects the result.
Rotation keeps the example focused. You can confirm success instantly without worrying about collisions, floor height, gravity, or camera framing. That makes it a very efficient first scripting lesson.
For this simple visual rotation example, Update is the clearer starting choice. FixedUpdate becomes more important when you are working with Rigidbody-based physics and want to synchronize with the physics step.
SerializeField lets a private field still appear in the Inspector. That means you can keep the code tidy while exposing the parts a learner should tweak during testing.
Yes. Unity's Rotate methods support different spaces. For a beginner lesson, local rotation is usually easier to understand first, then world-space rotation can be added as an experiment.