I’m making an “Item system”(With guns, grenades, food, etc…) and I have an Item Base C++ class for this. (I’m asking here first, cause it would be a long time to test this, sorry for that.)
Is it okay if I’m using one ItemBase class to every type of item (like armor, clothes, food, guns) and create child classes from that?
Should I create only a Blueprint child (for example: AK47 is a child of ItemBase, Steak is a child of ItemBase) or would it be better to create a c++ child from ItemBase called Guns.cpp and then I write the codes for the guns there and then create bp child from Guns.cpp like AK47, Glock etc.?
Hi, I just use one base class for items. But I also keep items and the actual things (like weapons) separated from each other. So the items I place in the world only contain a static mesh and the key of the item and the amount. The inventory is therefore also only a map from item key to amount. Also I have a map from item key to item data where all the data about all items is stored. And I keep things like classes or textures as soft references there, since I don’t want all of them to be loaded in memory at all times, but only load them into memory when I need them.
So when I want to spawn a weapon from an item (e. g. player wants to equip a weapon) I async load the weapon class associated with that item key and then spawn the weapon.