July 4, 2023

The /r/roguelikedev challenge for Unity: Parts 0 and 1

By bluesoul

I’m following along with a YouTube video that demonstrates making a Roguelike in Unity, following the methodology of the /r/roguelikedev challenge. However, I’m really unconvinced that YouTube is a great way of sharing whole big blocks of code changes at one, particularly when those blocks are pasted in rather than typed, so I’m writing this guide as I follow along. I’m thinking it’ll help me and it’ll also maybe help someone else.

You will need:

  • Unity Hub. I’m building this a little bit on Windows and a little bit on Apple Silicon, if you do that as well be sure that you pick the same version on both platforms for Unity Editor (it will prompt you to download the right version when you open the project).
  • An IDE that supports C# and can catch your basic problems. Unity can do this out of the box, but the consensus is to let an external IDE do the heavy lifting. I’m using JetBrains Rider, but Visual Studio Code is also completely acceptable. I’m using Rider because I already have a license for it and it offers native Unity integration.
  • Git and some version control. I use GitHub and most folks will do the same. On Windows I’m using WSL so I can make use of zsh and some handy Git shortcuts that would be more irritating in PowerShell, but really do what you want here, I’m not going to be double-checking you or anything. This isn’t even a strict requirement for the purposes of this exercise but being able to quickly see differences and revert changes is awfully nice.
  • That’s it, really. I don’t know a ton of C# myself going in. I’ve done the 2020 Roguelike tutorial with Python 3 and tcod, so I have some idea of what the finished product will look like. I don’t think I’ll be really getting into the basics of C# or programming in general since we’re both following along another source.

I will be occasionally researching things as I go and hopefully what I find will be useful to you as well. The code makes use of a lot of classes and Unity types that weren’t immediately apparent to me why they were chosen. I hate not knowing the answers to some of those things, so I try to track them down sometimes.

A note on the coding conventions in use on this site. Since this is a follow-along sort of thing, there’s an expectation that you will be copy-pasting blocks of code in, and also removing blocks of code as we continue to improve the game. I will be using strikethroughs for code to remove and underlines for code to add. Any code not marked with either one is code that already exists and is there to show you where the code we’re adding or removing is located. The title of the code block corresponds to the file you’re editing.

Here’s an example:

public class GameManager : MonoBehaviour
    public static GameManager Instance;
    // Start is called before the first frame update
    void Start()
    void Awake()

I played with some visual differences and decided to start all changes from the far left both to make it more visible (it’s very hard to see an underline under a single curly brace) and because it’s less work for me to mark up as I go. If we’re adding to an existing line later, it’ll just be underlined in the appropriate place.

That’s all for now, let’s start with Part 0, setup. This will also include the first pieces of project code and setup, so don’t skip it despite the number.

Pages: 1 2 3