Unity Beginner Project: Build a 2D Top-Down Adventure Controller
In this guide you will build the foundation of a small 2D adventure game in Unity. By the end, you will have a player that moves smoothly, a camera that follows, collectible keys, and a locked gate that opens when the player has the key.
This is a good first Unity project because it teaches the loop used in many games:
Read player input.
Move a character through the world.
Detect nearby objects.
Change game state when something happens.
Give the player feedback.
What You Will Make
The final scene is simple but meaningful: a player explores a small room, picks up a key, walks to a gate, and opens it. You can later expand this into a dungeon, farming game, RPG town, or survival prototype.
Step 1: Create the Unity Project
Open Unity Hub and create a new project:
Template: 2D
Name: TopDownAdventure
Location: anywhere inside your projects folder
When the project opens, create these folders in the Project window:
TEXT
1Assets/2 Art/3 Prefabs/4 Scenes/5 Scripts/
Save the current scene as:
TEXT
1Assets/Scenes/Main.unity
You do not need polished art. Use simple colored squares for now. Beginners often get stuck searching for assets before they understand the system. Build the system first.
Step 2: Create the Player
In the Hierarchy:
Right-click and choose 2D Object > Sprites > Square.
Rename it to Player.
Set its color to blue in the Sprite Renderer.
Add a Rigidbody2D.
Add a CapsuleCollider2D or BoxCollider2D.
Set the Rigidbody2D:
Gravity Scale: 0
Freeze Rotation Z: enabled
Collision Detection: Continuous if your player moves fast
The player should not fall because this is a top-down game.
Step 3: Add Movement Code
Create a script named PlayerMovement.cs in Assets/Scripts.
Press Play and walk into the key. It should disappear and log a message.
Step 7: Create a Locked Gate
Create a red rectangle sprite and rename it LockedGate.
Add:
BoxCollider2D
Leave Is Trigger disabled so it blocks the player.
Create LockedGate.cs.
CSHARP
1using UnityEngine;23public class LockedGate : MonoBehaviour4{5[SerializeField] private string lockedMessage ="Find the key first.";
Attach it to the gate.
Now test both paths:
Touch the gate before collecting the key. It should stay locked.
Pick up the key, then touch the gate. It should disappear.
Step 8: Turn It Into a Tiny Game Loop
Right now the system works, but it needs structure. Add a second room behind the gate and place a green square named Exit.
Create LevelExit.cs.
CSHARP
1using UnityEngine;23public class LevelExit : MonoBehaviour4{5 private void OnTriggerEnter2D(Collider2D other)6{7if(!otherCompareTag
Set the Player tag to Player, add a trigger collider to the exit, and attach the script.
You now have a complete tiny objective:
Explore.
Find key.
Unlock gate.
Reach exit.
Step 9: Beginner Debug Checklist
If something does not work, check these in order:
Is the script attached to the correct GameObject?
Is the collider set to trigger only when the script expects a trigger?
Does the player have the required component?
Is the Rigidbody2D on the moving object, not the wall?
Did you save the scene?
Is the GameObject active in the Hierarchy?
What To Add Next
Good next upgrades:
Add a UI text prompt instead of Debug.Log.
Add two keys and two gates.
Add a simple enemy that resets the room.
Add a coin counter.
Add scene loading when the player reaches the exit.
The important lesson is that Unity gameplay is usually many small components talking to each other. Keep each component responsible for one job, and your projects will stay easier to expand.