RPG Database in Unity

Silvio Carréra
5 min readApr 13, 2020
JRPG-Style Menu Sample

Building an RPG is tough. Even working on a basic one will demand a lot of content. You’ll need to create a world, the cities and fill it with characters. Also, your party members and a good amount of monster variety. Oh and don’t forget the weapons, spells, and items

Organizing all that becomes a problem. Using spreadsheets for balancing does help. You can make do with ScriptableObjects or some kind of text file but that becomes a hassle fast.

The drive behind this package is to make that easier. This tool facilitates creating the content for your RPG and then getting that into the game. All while trying to be as flexible as possible.

Getting Started

This post assumes you know to use Unity’s Package Manager to import a package from git.

With that said, the URL: https://bitbucket.org/carreraSilvio/rpgdatabase/

Core

Once you have it properly imported in your project. You’ll be able to access the database by going into Tools>RPG Database.

Actors

The bread and butter for your RPG are your characters. In this section, you can give each of them a name, a class, a starting level, and equipment.

Classes

Here is where you’ll spend most of your time when working on your actors. Alter the growth curve for each of the attributes. Define the weapon type he can use. Adds skills and when they’ll unlock.

The preview box will help you when tweaking values.

Skills

The basics are usage and scope. Usage defines the situation you can use the skill. Usually in battle and or in the field. While the scope will specify a target as either one or all allies and enemies.

The cost to use a skill can be either MP or HP. This allows you to build spells for things like vampires. You can build classes that use HP for all their skills instead of MP as well.

The effect type can either be: recover, damage or clear state. The names are straightforward but there are some observations. You can make skills to recover HP but also MP. Same with damage skills, you can also damage the HP or MP.

For the damage amount, you can use percentage and even add some amount of variance to the final amount.

Items

This section is quite like the skills section. That’s because they both can alter one or more target’s attributes.

The small difference is that items are not bound to any character class. They also have price and type. You can use the type to distinguish between common items and something like quest items.

Weapons

Like items, weapons also have a price and a type. The weapon type is more specific and you can bind it to a class. The rest is the list of attributes and how this weapon affects them. You can use negative values and create weapons that increase strength but reduce agility.

Configuration

Weapon Types

A simple list for you to edit the weapon types you want. Sword, daggers, rapiers, bows, longbows, crossbows, go wild with it.

Attributes

What is an actor if not a pile of attributes, right? In many RPGs, the HP will go up to a max of 99 while others may differ. You can choose the start and max value. A level 1 actor would have the start HP you set here and upon leveling up it would never pass the max value.

Code

With all configured to your liking, remember to save the changes afterward. To use the data in your project is quite easy. Here’s the code to get you started:

//Loading database
var _database = new RPGDatabaseManager();
_database.Load();

//Fetching data
var actorList = _database.FetchEntry<ActorDataList>();
foreach(var actor in actorList)
{
var className = _database.FetchClassData(actorData.classId).name;
var hpAtLv = _database.FetchAmount(actor.Id, 10, ActorAttributeType.HP);
Debug.Log($"Actor name is {actor.name}");
Debug.Log($"Actor class is {className}");
Debug.Log($"Actor HP at level 10 is {hpAtLv}");
}

Samples

If you’re still lost. Don’t worry. There’s also a Sample to import that shows how to load the data and use it into a JRPG-style menu.

Closing

This tool was made with RPGs in mind. But, since it’s common for non-RPG games to include mechanics like leveling up, growing stats and skills it suits other types of projects as well.

In the end, it’s just data for you to read and work with it in your systems. So give it a try on your next project.

--

--