How to create a 2D Roguelike in Unity - Part 1 Step-to-step tutorial guide to create a 2D Roguelike videogame in Unity. Part 1: Project Setup, Pixel Art Graphics and Control System

Creare un Roguelike 2D in Unity - Parte 1

Who hasn’t dreamed of creating their own video game? Maybe a small dungeon crawler, with a top-down view, a hero moving through dark rooms filled with monsters, and that magical sense of unpredictability that only a roguelike can offer. If you too, like us, have dreamed at least once of bringing your pixel-art world to life, then you’re in the right place.

In this three-part article series, we’ll guide you step by step through the creation of a simple but complete 2D roguelike developed in Unity, using as our foundation the open-source project 2DRogueTest, freely available on GitHub. Of course, this example isn’t meant to be a commercial game or a visual masterpiece: it’s a concrete example, created to help beginner developers find their way through scripts, prefabs, tilemaps, and gameplay logic.

In this Part 1, we’ll start with project setup, sprite import, and creation of a basic movement system for the player character. Nothing complicated or stressful: everything is explained calmly, with practical examples, existing files, and the idea of having fun while learning.

Ready to take your first steps into your digital dungeon? Then let’s go!

1. Creating the Unity Project

Open Unity Hub and create a new 2D project called 2DRogueTest. For simplicity, we’ll use the Built-in Render Pipeline, though you can easily adapt it to URP.

Make sure the project has the following initial structure:

These folders already exist in the GitHub repository.

Open the scene /Scenes/SampleScene.unity, which is the main game scene.


2. Importing Pixel Graphics

In the /Sprites folder you’ll find the sprites used in the game, including:

  • character.png – our player character
  • enemy.png – the basic enemy
  • tileset.png – tileset for floors and walls

Unity will import them as Texture Type: Sprite (2D and UI). Set the Pixels Per Unit consistently (e.g., 16 or 32) to maintain pixel-perfect proportions.

In the Sprites.meta file you’ll find the correct import and slicing settings.


3. Adding the Player

In the project, the main GameObject for the player is found in the prefab /Prefabs/Player.prefab. It consists of:

  • a Sprite Renderer with character.png
  • a Rigidbody2D (Body Type: Dynamic)
  • a BoxCollider2D

It’s linked to a script called PlayerController.cs located in /Scripts/PlayerController.cs.

Here’s an excerpt of the code:

This simple script allows for smooth movement in four directions.


4. Setting Up the Map and Environment

The initial map is built at runtime, but the project includes a static example in the SampleScene to test movement. The floor and walls are created by manually placing tiles from tileset.png.

Alternatively, you can import Unity’s 2D Tilemap Editor package to create maps directly in the editor.


5. Camera and Player Follow

The scene’s main camera uses a script called CameraFollow.cs found in /Scripts/CameraFollow.cs. Here’s the code:

To make the script work, just assign the player’s transform to the target field.


6. Test and Build

At this point, you can run the SampleScene, move the character, and verify that everything works. The map is still static, but in the next part we’ll add enemies, AI, and a combat system.


Conclusion

In this first part, we’ve built the foundations: player, movement, map, and camera. Everything is already available in the GitHub project 2DRogueTest. In the next part we’ll focus on enemy AI and combat mechanics.

Fork me on GitHub

About Ryan

IT Project Manager, Web Interface Architect and Lead Developer for many high-traffic web sites & services hosted in Italy and Europe. Since 2010 it's also a lead designer for many App and games for Android, iOS and Windows Phone mobile devices for a number of italian companies. Microsoft MVP for Development Technologies since 2018.

View all posts by Ryan

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.

This site uses Akismet to reduce spam. Learn how your comment data is processed.