How to do items database for RPG game?

Hi everyone.
I’m working on 2D RPG game and I need a database of items like rings, potions, spells etc.
I was searching on google for answer but everyone says I need to use xml or SQLite and it seems really hard to me. Is there easier way to do it?
Thank you.

1 Like

A simple approach to get started could be to just use ScriptableObjects Unity - Manual: ScriptableObject.

You could have one ScriptableObject called an ItemDatabase, with perhaps a list of other ScriptableObjects called Items.

Thanks for reply. But then I think there will be one script(ScriptableObject) for every single item so I don’t know if its a good idea.

You won’t have a script per item. You will have a script per ScriptableObject type. For example you will have a script like:

using UnityEngine;

[CreateAssetMenu(fileName = "New Item", menuName = "ScriptableObjects/Item")]
public class ItemScriptableObject : ScriptableObject
{
    public string Name;
    public Texture2D Icon;
    public int Cost;
    public ItemType ItemType;
}

public enum ItemType {
  Weapon,
  Potion,
  Accessory,
  Spell
}

Then you can create new items in your project by going to Assets → Create → ScriptableObjects → Item. So one item script can handle all the items in your game.

Ok that looks interesting but what if items have different stats? For example ring with attack boost and sword with damage etc.?

Make another StatBonus object and have a list of those on the Item script? The possibilities are limitless.

1 Like

Thank you I didn’t thought about it. I will try this method.