I’m not quite sure how to go about adding items without creating a separate script for all of my items. I’m currently using a json file to store my item info and a function to add different items to the inventory. As far as equipping goes, I’m pretty lost. If I could get help with either system I’d be grateful.
There Are quite a few YouTube tutorials.
In general you want all items to share a common base class they inherit from.
So you’ll have
Class items : monobehavior
Class weapons : items
Class potions : items
Class sword : weapons
So sword is a weapon, a weapon is a item so sword is also as item.
Then you have equipped be items and use checks to ensure it’s allowed.
So
Equip (item toEquip)
{
If (toEquip.type != weapon)
Return;
Equipped = toEquip;
}
Let me know if this doesn’t make sense, Google inheritance as well for help understanding how classes inherit other classes.
How you have a parent class like item, a child class like weapon, which is itself a parent of the child class sword