DEV Community

Cover image for "How to Create Your First 2D Game in Unity (Beginner-Friendly)
Prasoon  Jadon
Prasoon Jadon

Posted on

"How to Create Your First 2D Game in Unity (Beginner-Friendly)

🎮 How to Create Your First 2D Game in Unity

If you’re just starting with game development, Unity is one of the best engines to learn. It’s beginner-friendly, powerful, and widely used for both 2D and 3D games.

In this post, we’ll create a simple 2D game step by step using Unity Hub and C#, even if you’ve never made a game before.


🧰 What You Need

Before starting, make sure you have:

  • A PC or Laptop (Windows / macOS / Linux)
  • Unity Hub (Free)
  • Basic understanding of mouse & keyboard 😄

👉 You do NOT need prior coding experience.


📥 Step 1: Install Unity

  1. Download Unity Hub from the official Unity website
  2. Open Unity Hub → Go to Installs
  3. Install an LTS (Long Term Support) version
  4. While installing, check:
  • ✅ 2D Game Development
  • ✅ Visual Studio (for C#)

🆕 Step 2: Create a New 2D Project

  1. Open Unity Hub
  2. Click New Project
  3. Select 2D Core template
  4. Name your project (example: MyFirst2DGame)
  5. Click Create

Unity will open a new editor window 🎉


🖼️ Step 3: Understand the Unity Editor

Important panels:

  • Scene – Where you design the game
  • Game – What the player sees
  • Hierarchy – List of all objects
  • Inspector – Object properties
  • Project – Assets like scripts, images, sounds

Take a minute to explore them.


🧱 Step 4: Add a Player Sprite

  1. Right-click in Hierarchy2D ObjectSprite
  2. Rename it to Player
  3. In Inspector, choose a color or sprite
  4. Add physics:
  • Click Add ComponentRigidbody2D
  • Set Gravity Scale = 0

🧠 Step 5: Create Player Movement Script

  1. Right-click in ProjectCreateC# Script
  2. Name it PlayerMovement
  3. Double-click to open the script

✨ PlayerMovement.cs

using UnityEngine;

public class PlayerMovement : MonoBehaviour
{
    public float speed = 5f;

    void Update()
    {
        float moveX = Input.GetAxis("Horizontal");
        float moveY = Input.GetAxis("Vertical");

        Vector2 movement = new Vector2(moveX, moveY);
        transform.Translate(movement * speed * Time.deltaTime);
    }
}
Enter fullscreen mode Exit fullscreen mode
  1. Save the file
  2. Drag this script onto the Player object

▶️ Step 6: Test the Game

  • Click the Play ▶️ button
  • Use Arrow Keys / WASD to move the player

Congrats! Your first game mechanic works 🎉


🧱 Step 7: Add Boundaries (Optional)

  1. Create a new 2D Object → Sprite
  2. Resize it as walls
  3. Add BoxCollider2D
  4. Make sure Player also has a Collider2D

Now the player won’t pass through walls.


🎨 Step 8: Improve the Game

Things you can add next:

  • 🎵 Background music
  • ⭐ Score system
  • 👾 Enemies
  • 🏁 Win / Lose screen
  • 📱 Mobile controls

Game development is about small steps.


🚀 Final Thoughts

Your first game doesn’t need to be perfect.
What matters is:

  • Learning by building
  • Making mistakes
  • Improving step by step

Unity is a powerful engine, and this is just the beginning.

If you’re a student or beginner like me — keep going 💙


🔗 Helpful Resources

  • Unity Learn (Free courses)
  • Unity Documentation
  • GameDev communities on dev.to

Happy Game Developing! 🎮🚀

Top comments (0)