Learn to distinguish between a GameObject (container) and Components (behaviors/parts). Create a working object by adding and removing components.
- Open Unity (any 2020+ version)
- In the Hierarchy window → Right-click →
Create Empty - Name the object
MyRobot - Look in the Inspector: what components are already there? (only
Transform)
- Select
MyRobot - Click
Add Component→Mesh Filter→ chooseCube(orSphere) - Add
Mesh Renderer(if not added automatically) - Create a material: Right-click in Project →
Create→Material, name itRobotMat, color it red - Drag
RobotMatontoMyRobot(or assign it inMesh Renderer→Element 0)
➡️ Now MyRobot is visible. But it doesn't move or interact.
Add Component→RigidbodyAdd Component→Box Collider(automatically fits the cube's size)
➡️ Press Play. The object will fall down due to gravity. Stop the game.
- Create a C# script: Right-click in Project →
Create→C# Script, name itRotator - Open the script (double-click) and write:
using UnityEngine;
public class Rotator : MonoBehaviour
{
public float speed = 30f;
void Update()
{
transform.Rotate(Vector3.up, speed * Time.deltaTime);
}
}- Save the script. Drag it onto
MyRobotin the Inspector (or onto the object in Hierarchy)
Perform each step one by one and observe the result:
- Disable
Mesh Renderer(uncheck the box) → the object becomes invisible but still rotates (if Play is on) — becauseRotatoris still working. - Disable
Rotator→ rotation stops. - Remove
Rigidbody(three dots → Remove Component) → gravity and physics are gone. - Create a second object (
Create Empty→ name itMyRobot2) and drag the existingRotatorscript from the Project window onto it. It will also rotate.
- How many GameObjects are in the scene after Part 5? (hint: every object in Hierarchy is a GameObject)
- Can you add two identical
Rigidbodycomponents to one GameObject? (try it) - What happens if you delete the
Transformcomponent?
✅ Success criteria: You can create an object, make it visible, physical, with rotation logic — and explain which part is the container (GameObject) and which are components.