Objective
- Open and navigate the Unity Editor.
- Create a simple 2D scene.
- Add a Player object that moves with arrow keys or WASD.
- Understand GameObjects, Components, and Play Mode.
What You’ll Need
- Unity Hub installed.
- Unity Editor 2022 or newer.
- A new 2D project named: MyFirstUnityGame.
Vocabulary
| Term |
Meaning |
| Scene |
A level or environment in your game. |
| GameObject |
Any item in your scene (player, wall, light, etc.). |
| Component |
Adds behavior or properties to a GameObject. |
| Transform |
Controls position, rotation, and scale. |
| Play Mode |
Lets you test your game in the Unity Editor. |
Step-by-Step Instructions
Step 1 — Start a New Project
- Open Unity Hub.
- Click New Project → 2D (Core).
- Name it PX_lastname_UnityA and click Create project.
Step 2 — Set Up the Scene
- In the Hierarchy, right-click → 2D Object → Sprite → Square.
- Rename it to Player.
- In the Inspector, click the Color box and pick a color.
Step 3 — Add Movement with a Script
- In the Project window, right-click → Create → C# Script.
- Name it PlayerMovement.
- Double-click the script to open it in your code editor.
- Replace the contents with the code below and save.
// PlayerMovement.cs
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
public float speed = 5f;
void Update()
{
float moveX = Input.GetAxis("Horizontal");
float moveY = Input.GetAxis("Vertical");
transform.Translate(new Vector2(moveX, moveY) * speed * Time.deltaTime);
}
}
- Drag the PlayerMovement script onto the Player GameObject in the Hierarchy.
Step 4 — Test the Game
- Click the Play button at the top of Unity.
- Use Arrow keys or WASD to move the player square.
- Click Play again to stop testing.
Tip: If your player doesn’t move, confirm the script is attached to the Player object and check the Console for errors.
Challenge Extensions
- Change the player’s color when moving (hint:
GetComponent<SpriteRenderer>().color).
- Add an Obstacle GameObject and try not to touch it.
- Make the player bounce off screen edges using simple boundary checks.
Reflection Questions (Answer them in the private comments on google classroom.
- What is a GameObject in Unity?
- What does the Transform component control?
- Why is
Update() called every frame?
- How does
Time.deltaTime help movement feel smooth?
Submission
Submit 4 files:
- Your PX_lastname_UnityScene.png with your Unity Player visible.
- Your PX_lastname_codeEditor.png showing the
PlayerMovement script.
- Your PX_lastname_UnityA.mp4 Video showing game running.
- Your PX_lastname_UnityA.unity actual Unity program.
Use these filenames:
Save the files into your google drives under your class period and upload to Google Classroom.