---
title: "Set up your 2D game world"
content_type: tutorial
url: "https://learn.unity.com/pathway/game-development/unit/create-a-basic-2d-game/tutorial/set-up-your-2d-game-world?language=en"
language: en
container_type: pathway
container_title: "Game Development"
container_url: "https://learn.unity.com/pathway/game-development.md?language=en&version=6.3"
unit_title: "Create a basic 2D game"
unit_url: "https://learn.unity.com/pathway/game-development/unit/create-a-basic-2d-game?language=en&version=6.3"
standalone_markdown_url: "https://learn.unity.com/tutorial/set-up-your-2d-game-world.md?language=en&version=6.3"
previous_title: "Introduction to Unit 3"
previous_url: "https://learn.unity.com/pathway/game-development/unit/create-a-basic-2d-game/tutorial/introduction-to-game-dev-unit-3?language=en&version=6.3"
previous_markdown_url: "https://learn.unity.com/pathway/game-development/unit/create-a-basic-2d-game/tutorial/introduction-to-game-dev-unit-3.md?language=en&version=6.3"
next_title: "Make a flying obstacle prefab"
next_url: "https://learn.unity.com/pathway/game-development/unit/create-a-basic-2d-game/tutorial/make-a-flying-obstacle-prefab?language=en&version=6.3"
next_markdown_url: "https://learn.unity.com/pathway/game-development/unit/create-a-basic-2d-game/tutorial/make-a-flying-obstacle-prefab.md?language=en&version=6.3"
difficulty: beginner
duration_minutes: 20
unity_version:
  - "6.0"
  - "6.3"
supported_unity_versions:
  - name: "6.0"
    url: "https://learn.unity.com/tutorial/set-up-your-2d-game-world.md?language=en&version=6.0"
  - name: "6.3"
    url: "https://learn.unity.com/pathway/game-development/unit/create-a-basic-2d-game/tutorial/set-up-your-2d-game-world.md?language=en&version=6.3"
last_updated: "2026-08-04T14:21:18.000Z"
---

# Set up your 2D game world

Preview the Sprite Flight game, then create a new 2D project and build a walled play area for your scene.

In this tutorial, you'll preview the finished version of Sprite Flight: a simple, 2D arcade game where you steer a triangular ship to dodge flying obstacles. Then, you'll create a new Unity project using Unity’s 2D template and set up the basic play area for your 2D game, complete with walls around the edges of the screen.

## 1. Overview

Let’s start by previewing the game you're going to build. In Sprite Flight, you control a triangular ship that flies around a rectangular game space. The goal is to survive for as long as possible by avoiding the moving obstacles. The longer you stay alive, the higher your score climbs. If your ship collides with an obstacle or wall, it explodes — and it’s game over.

By the end of this course, you'll have created your own version of this game from scratch. Along the way, you’ll learn how to do the following:

- Set up and navigate Unity’s 2D environment
- Use physics components to simulate bouncing and movement
- Write simple C# scripts and attach them to GameObjects
- Build and display a live scoring system
- Handle collisions, UI, and game restart logic

Previewing the final game helps you understand where you’re headed and why each step along the way matters.

[Video](https://connect-mediagw.unity.com/h1/20250519/videos/69f52e6d-cfc3-49d6-b613-7d155aa051a8_1.1_-_Course_overview.mp4)

**1.  Play the web version of the demo game:**

- Open the [demo version of Sprite Flight](https://play.unity.com/en/games/f87bfd00-6eb9-419e-b309-17e9ec005011/sprite-flight).
- Click or tap anywhere to steer the ship in that direction.
- Your score increases the longer you stay alive.
- Avoid the flying hexagons and the outer walls.



**2.  Observe how the game is built:**

- Notice the basic shapes: a triangular player, square borders, and hexagon obstacles.
- Pay attention to how the movement feels — there's momentum, bounce, and randomness.

You’ve now experienced the final version of Sprite Flight and have a clear goal in mind. Next, you’ll start your own project and begin building the game world step-by-step.

## 2. Create a new 2D project

Now that you’ve previewed the final game, it’s time to start building it yourself. In this step, you’ll create a new Unity project using the **Universal 2D** template. This template sets up your environment with settings and tools suited for 2D games.

![](https://connect-mediagw.unity.com/h1/20250519/learn/images/fb20f22e-dab8-4318-a624-ee98511e6a72_1.2_-_Create_a_new_2D_project.png)

**1.  Launch Unity Hub:**

- Open the **Unity Hub** on your computer.
- If you don’t have Unity Hub or a version of Unity 6 installed yet, download and install it from[ unity.com/download](https://unity.com/download).

**2.  Create a new project:**

- Select the **New Project** button.
- Select the **Universal** **2D** template.
- Name your project “Sprite Flight” or something similar.
- Set a project location on your computer where you can easily find it.
- Select **Create Project** and wait while Unity sets up your files and opens the Editor.

**Important:** Make sure you select the **Universal 2D** template or your project won’t be configured properly to create this project.


You now have a fresh Unity project using the **Universal** **2D** template, ready for development.

## 3. Set up your layout

Unity’s layout is customizable, and organizing your windows early helps you work more efficiently. Also, setting your layout so that it matches the instructions and screenshots in this course will make the tutorials easier to follow.

In this step, you’ll arrange your workspace so that you can see the **Scene** view, **Game** view, **Hierarchy**, **Project**, and **Inspector** windows all at once.

[Video](https://connect-mediagw.unity.com/h1/20250519/videos/29489019-d85c-48c9-9130-44ccf7809163_1.3_-_Set_up_your_layout.mp4)

**1.  Select the 2 by 3 layout preset:**

- In the upper-right corner of the Unity Editor, open the **Layout** dropdown and select **2 by 3**.


**2.  Move the Project window below the Hierarchy window:**

- Drag the **Project** window so it sits below the **Hierarchy** window.
- Drag the upper-edge of the **Project** window up so that it aligns with the top of the **Game** view.


**3.  Tidy the Project window view:**

- In the **Project** window, select the **More** (**⋮**) menu and ensure that the **One Column** layout is enabled.

Your layout is now configured so you can comfortably access all the tools you’ll need during development and more easily follow along with this course.

## 4. Navigate around a new 2D scene

Creating a new scene ensures a clean, organized starting point for your game. In this step, you’ll set up and save a dedicated scene.

[Video](https://connect-mediagw.unity.com/h1/20250519/videos/0c370636-b84a-472a-8f4d-1db2a909d533_1.4_-_Navigate_around_a_new_2D_scene.mp4)

**1.** **Create your new scene:**

- In the **Project** window, right-click the **Scenes** folder and select **Create** > **Scene** > **Scene**.
- Rename the new scene “Game”.

**2.  Open the Game scene:**

- Double-click the **Game** scene to open your new scene.
- A dialog stating “Scene(s) have been modified” might appear, referencing the **SampleScene**. When prompted, select **Don’t Save**, as you have created a new scene, and so **SampleScene** is no longer needed.
- You’ll now see the name of your scene (**Game**) appear at the top of the **Hierarchy** window.

**3.  Practice navigating in 2D:**

- Use your **scroll wheel** (or **two-finger swipe** on a trackpad) to zoom in and out of the **Scene** view.
- Ensure the **View** tool (hand) is selected from the **Tools** overlay in the **Scene** view, then hold **right-click** and **drag** to pan around the scene.

**Tip:** Navigating the **Scene** view with these gestures will help you quickly place and adjust GameObjects throughout this course. To learn more about scene navigation, check out the **[Explore the Unity Editor tutorial](https://learn.unity.com/tutorial/explore-the-unity-editor-1#6273f00fedbc2a7f158cc1f1).**

You now have a new empty scene open in the Unity Editor and understand how to navigate 2D space.

## 5. Add an Obstacle sprite

To build your game world, you'll start by adding a simple hexagon-shaped obstacle to your scene. In Unity, 2D objects are made using **sprites** — flat images that can be moved, colored, and given physical properties. You’ll place a hexagon-shaped sprite at the center of the scene.

Unity uses an (**x**, **y**, **z**) coordinate system. In this system, the **x-axis** runs left to right, and the **y-axis** runs up and down. In 2D games, the **z-axis** is ignored — since it goes forward and back in the scene. The **origin** — the center of the scene — is located at position (**0**, **0**, **0**).

[Video](https://connect-mediagw.unity.com/h1/20250519/videos/235318dc-f28a-4db5-b2e3-39ad59f0c2e3_1.5_-_Add_an_Obstacle_Sprite.mp4)

**1.  Add a 2D hexagon sprite:**

- Right-click in the **Hierarchy** window and select **2D Object** > **Sprites** > **Hexagon Flat Top**.
- This creates a new 2D GameObject in your scene using Unity’s built-in **Hexagon** shape.

**2.  Rename and reposition the GameObject:**

- Rename the new GameObject “Obstacle”.
- In the **Inspector** window, set its **Transform** > **Position** to **X**=**0**, **Y**=**0**, **Z**=**0**.

**Note:** In 2D, the **z-axis** value is still required, but it won’t affect rendering or gameplay.

**3.  Change the color (optional):**

- In the **Sprite Renderer** component, select the **Color** swatch.
- Select a new color from the **Color** window to help the obstacle stand out visually in the scene.

You've now placed a static obstacle in the world, centered at the origin. You'll later give it physics properties so it can move and bounce — but for now, it's a visual reference point in your 2D space.

## 6. Change the size and background of the camera

In 2D games, the default camera uses an **Orthographic projection**, meaning it shows the world without perspective (objects don’t get smaller as they move away). Instead of zooming in or out with the camera, you control how much of the scene is in view by changing the **Size** property.

Right now, the area in view is a little bit too small. In this step, you'll adjust the **orthographic size** of the **Main Camera** to zoom out a bit, and if you want, you can also change the background color.

[Video](https://connect-mediagw.unity.com/h1/20250519/videos/b34b4cc6-da1f-483c-96c0-701e464e6f2e_1.6_-_Change_the_size_and_background_of_the_camera.mp4)

**1.  Select the Main Camera:**

- In the **Hierarchy** window, select the **Main Camera** GameObject.
- In the **Inspector** window, find the **Camera** component.

**2.  Adjust the orthographic size:**

- Under the **Projection** section, make sure the **Projection** property is set to **Orthographic**.
- Increase the **Size** property to a value around **7.5**.

**Note:** A higher size zooms the camera out, showing more of the scene.

- Watch the white rectangle in the **Scene** view expand as you adjust this setting.


**3.  Change the background to a solid color:**

- Use the foldout (triangle) to expand the **Environment** section, then change the **Background Type** property from **Skybox** to **Solid Color**.
- Select the **Background** swatch and select a background color that complements your obstacle.

**Note:** A **skybox** is a 3D environment wrapper used in 3D games. Since you're making a 2D game, a solid background color is simpler and more appropriate.

After this step, your camera shows a larger area of the game world, and the background color is adjusted to your liking.

## 7. Create the first screen border

Your player and obstacles need to stay within visible bounds, so it's time to build a screen boundary.

You'll create a 2D sprite to act as the bottom wall, and use Unity’s **Rect Tool** to position and size it. This tool lets you directly manipulate the shape and size of 2D GameObjects in the **Scene** view.

[Video](https://connect-mediagw.unity.com/h1/20250528/videos/661e4061-f370-4616-9fd2-9628ed84f839_1.7_-_Create_the_first_screen_border.mp4)

**1.  Add a square sprite to act as the bottom border:**

- In the **Hierarchy** window, right-click and choose **2D Object** > **Sprites** > **Square**.
- Rename the new GameObject “Border_Bottom”.


**2.  Switch to the Rect Tool:**

- With the **Border_Bottom** GameObject selected, select the **Rect** tool from the **Tool** overlay in **Scene** view.

**Tip:** You can also press **T** with your cursor in the **Scene** view to activate the **Rect Tool**.

- You’ll now see handles around the GameObject that let you resize it directly in the **Scene** view and a circle at the sprite’s center which you can click and drag around.


**Note:** Depending on how zoomed out your **Scene** view is, you might need to zoom in to see the handles around the **Border_Bottom** GameObject.

**3.  Resize and position the wall:**

- Use the **Rect** tool to stretch the border horizontally and move it downward to sit at the bottom edge of the camera bounds.
- You can use the **white camera rectangle** in the **Scene** view as a guide.
- If you can’t see the camera bounds clearly, zoom out with your mouse wheel or **right-click** and **drag** to navigate in the **Scene** view.



After this step, your game now has its first world boundary — a solid wall at the bottom of the screen to stop obstacles and keep the player inside the play area.

## 8. Duplicate to make other screen borders

With the bottom border in place, you’ll now add the remaining three screen borders: top, left, and right. Rather than creating each from scratch, you’ll **duplicate** the existing object and reposition it using the **Rect Tool**.

[Video](https://connect-mediagw.unity.com/h1/20250519/videos/d36a9ae9-babc-4c78-9478-a90f325e9c47_1.8_-_Duplicate_to_make_other_screen_borders.mp4)

**1.  Select and duplicate the bottom border:**

- In the **Hierarchy** window, select the **Border_Bottom** GameObject.
- Press **Ctrl**+**D** (macOS: **Cmd**+**D**) to duplicate it, then rename the new GameObject to ”Border_Top”.


**2.  Move and resize the top border:**

- Use the **Rect** tool (press **T** if needed) or the **Move** tool (press **W**) to move the **Border_Top** GameObject to the top edge of the camera bounds.


**3.  Repeat for the left and right borders:**

- Duplicate the **Border_Bottom** GameObject again to create **Border_Left**, then position and resize it along the left edge.
- Duplicate the **Border_Left** GameObject once more to create **Border_Right**, then place it along the right edge.

**Tip:** Use zoom and pan controls (**scroll** **wheel** + **right**-**click** and **drag**) to align the borders accurately, but don’t worry about perfection — close enough is fine for now.


You now have all four walls in place, forming a boundary to contain gameplay and GameObjects within the screen area.

## 9. Lock the aspect ratio and adjust borders

To make sure your game always fits the screen the way you intend, you can set your **Game** view to a fixed **aspect ratio**. By default, Unity’s **Game** view uses a flexible **Free Aspect** mode, which can stretch or crop your game depending on window size. In this step, you’ll set a fixed **16:9 aspect ratio**, which is a common screen format used on phones and monitors.

You then might need to adjust your screen borders to make sure they align correctly with the new display shape.

[Video](https://connect-mediagw.unity.com/h1/20250519/videos/365e3f11-0b2d-435e-a059-f9e3db081484_1.9_-_Lock_the_aspect_ratio_and_adjust_borders.mp4)

**1.  Change the Game view aspect ratio:**

- In the **Game** view, open the **aspect ratio** dropdown (likely labeled **Free Aspect**) and select **16:9**.

**2.  Experiment with the Game view size:**

- Drag the edge of the **Game** view to see how the visible space changes.
- Notice how a fixed aspect ratio maintains a consistent layout, while “Free Aspect” stretches it.


**3.  Adjust the borders to fit:**

- In the **Scene** view, use the **Rect** tool (press **T**) to reposition and resize the borders so they neatly frame the 16:9 camera bounds.

By locking the aspect ratio and resizing your borders, you ensure that your game layout looks correct no matter how wide or tall the player’s screen is.

## 10. Organize the Hierarchy window and Assets folder

As your project grows, good organization will save time and reduce confusion. In this step, you’ll group related GameObjects inside an empty parent GameObject and tidy up your **Project** window by moving assets into folders.

[Video](https://connect-mediagw.unity.com/h1/20250519/videos/9b30454d-b4ff-45cc-a4db-f62ff3cd7b5d_1.10_-_Organize_the_Hierarchy_and_Assets_folder.mp4)

**1.  Group the borders in an empty GameObject:**

- Right-click in the **Hierarchy** window and select **Create Empty**.
- Rename the new GameObject ”Borders”.


**2.  Move all border GameObjects inside the new parent:**

- Use **Shift**+**click** or **Ctrl**+**click** (**macOS: Cmd**+**click**) to select **Border_Bottom**, **Border_Top**, **Border_Left**, and **Border_Right**.
- Drag them all into the **Borders** GameObject in the **Hierarchy** window.


**3.  Organize your Project window:**

- Use **Ctrl**+**click** (macOS: **Cmd**+**click**) to select all assets that aren’t in the **Scenes** folder (such as the **DefaultVolumeProfile** and **InputSystem_Actions**).
- Drag them into the **Settings** folder to keep your project tidy.


Your scene and assets are now neatly organized, making it easier to find and modify elements as you build more features.

## 11. Optional: More things to try _(Optional)_

Try these optional activities to challenge yourself, build your skills, and improve your project.

Each challenge is tagged as **Easy**, **Medium,** or **Expert** difficulty so that you know what to expect. You can complete one, all, or none of them — it’s totally up to you. If you’re not interested in doing these challenges, mark this step as complete and proceed to the next tutorial.

## Easy: Save a custom layout

If you've arranged your Unity windows in a way you like, you can save that layout for future use.

![](https://connect-mediagw.unity.com/h1/20250519/learn/images/c60cb8a0-d1b0-4b11-ad34-03caf03e8b4d_1.11_-_Easy_-_Save_a_custom_layout.png)

- In the upper-right corner of the Editor, open the **Layout** dropdown.
- Select **Save Layout…**, give it a name like “2D Game Layout,” and save.

## Medium: Change the colors of your obstacle and borders

Make your game feel more unique by customizing the color of your GameObjects.

- In the **Hierarchy** window, select the **Obstacle** GameObject or one of the border GameObjects.
- In the **Inspector** window, locate the **Sprite Renderer** component.
- Select the **Color** swatch and select a new color in the **Color** window.
- Repeat for each GameObject you want to recolor.

![](https://connect-mediagw.unity.com/h1/20250519/learn/images/a9f2bd8d-fec9-433a-a01e-083884d3a345_1.11_-_Medium_-_Change_the_colors.png)

If your camera background still uses the default color, try adjusting that too:

- Select the **Main Camera** in the **Hierarchy** window.
- In the **Inspector** window, change the **Background Type** property from **Skybox** to **Solid** **Color**.
- Select a background color that complements your new GameObject colors.

## 12. Next steps

You’ve built the foundation of your 2D game world by adding an obstacle, setting up the camera, adding screen boundaries, and organizing your scene.

In the next tutorial, you’ll bring your first obstacle to life by adding physics, colliders, and turning it into a flying prefab.
