How to Make a 2D Game in Unity (2025 Guide)

๐น๏ธ How to Make a 2D Game in Unity
Are you ready to build your very first 2D game in Unity? Whether you’re a student, hobbyist, or aspiring game developer, this step-by-step guide will help you create a simple 2D game using Unity โ from setup to APK export.
In 2025, Unity remains one of the most powerful and beginner-friendly engines for mobile game development. Let’s get started!
๐ง What You’ll Learn:
- Unity setup for 2D game dev
- Character movement, obstacles, scoring
- UI and sound integration
- How to export APK for Android
- Bonus: Play Store publishing tips
๐ ๏ธ Step 1: Setup Unity for 2D Game Development
1.1 Install Unity Hub
Go to Unityโs official website and download Unity Hub. This is where you manage your Unity versions and projects.
1.2 Install Unity 2022 or 2023 LTS (with 2D Core Template)
- Open Unity Hub
- Click on Install โ Select latest LTS version
- Add these modules:
- Android Build Support
- OpenJDK, SDK & NDK
๐ฏ Tip: Use Unity LTS version for stability and Play Store compatibility.
๐งฑ Step 2: Create New 2D Project
- Open Unity Hub โ โNew Projectโ โ Choose โ2D Coreโ
- Name it:
MyFirst2DGame
- Create folder structure:
Assets/Scripts/
Assets/Sprites/
Assets/Prefabs/
๐จ Step 3: Import Sprites & Assets
Use:
- OpenGameArt.org
- Unity Asset Store (free 2D sprites)
Add:
- Background image
- Player sprite
- Obstacle sprite (like spikes or fire)
๐ฅ Optional: [Download my free Unity asset pack โ Gumroad link]
How can I install WhatsApp on my iPad 2024?
๐ฎ Step 4: Player Movement Script
Create PlayerMovement.cs
in Assets/Scripts/
:
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
public float moveSpeed = 5f;
void Update()
{
float moveX = Input.GetAxis("Horizontal");
transform.position += new Vector3(moveX, 0f, 0f) * moveSpeed * Time.deltaTime;
}
}
- Attach this script to your player GameObject
- Add Rigidbody2D and BoxCollider2D components
๐ฏ This allows smooth left/right movement on keyboard or touch buttons.
โ Step 5: Add Obstacles & Game Over Logic
- Add an Obstacle prefab (e.g. spikes)
- Add
BoxCollider2D
to it - Add
tag
="Obstacle"
Create this script and attach to player:
void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.tag == "Obstacle")
{
Debug.Log("Game Over!");
// Add Game Over logic here
}
}
๐ฏ Step 6: Score System (Simple Timer)
Create a GameManager.cs
script:
using UnityEngine;
using UnityEngine.UI;
public class GameManager : MonoBehaviour
{
public Text scoreText;
private float score = 0;
void Update()
{
score += Time.deltaTime;
scoreText.text = "Score: " + Mathf.Floor(score).ToString();
}
}
๐ฏ Add this script to an empty GameObject. Attach a UI Text element.
๐ Step 7: Add Sound & UI
- Add jump or collision SFX (MP3 or WAV)
- Use
AudioSource
component to play sounds
Game Over UI:
- Create canvas with โGame Overโ text
- Add Replay and Quit buttons
- Use
SceneManager.LoadScene()
to restart
๐ฏ Bonus: Add pause functionality for polish.
๐ฆ Step 8: Build APK for Android
- Go to File โ Build Settings
- Select Android โ Click “Switch Platform”
- Set:
- Company Name
- Package Name (
com.vikas.myfirstgame
) - Version Code
- Minimum API Level (usually 21)
- Build APK
๐ Donโt forget to create a Keystore if you plan to publish.
๐ Bonus: Publish to Google Play Store
- Sign up at Google Play Console
- Pay $25 one-time fee
- Upload your .AAB file
- Add screenshots, description, icon
- Submit for review!
โ Once approved, your game will be LIVE globally!
๐ก Final Words
Congratulations ๐ You just made your first 2D game in Unity and built an Android APK ready for publishing!
๐งฐ Resources:
- ๐ฆ [Download full project files โ DM Me
- ๐ผ Need help publishing your game? Hire Me
- ๐ฌ Get more Unity guides โ Join my weekly newsletter
๐ Summary:
Step | Action |
---|---|
Setup | Install Unity Hub + Android Support |
Build | Create project, scripts, UI |
Export | APK generation |
Monetise | Publish or sell template |