Best way to store inventory items in c++
Hello, Currently I have my inventory class, which is simply a uobject that the player has assigned to him. I also have my pickupitem actor class which then has sub classes for weapons, clothing etc. My goal is to create some sort of list of that holds all of these items. My first thought was a Tarray, seems like it would be simple enough to create a method to organize and swap out items in order to hold them/drop them. Of course I am not sure if it is the best way to store the data. I know there is plenty of tutorials on how to do this in blueprints, but I try and avoid those like the plauge (besides for gui). If someone could help me out, that would be great. Thanks
asked Apr 15 '16 at 11:52 PM in C++ Programming
TArray will work fine. Just make a TArray of PickUpItem classes and add them as you get them. You may even consider making a 2D array so that it's easier to keep track of different types of items, i.e. Inventory holds weapons,  armor, etc etc. Depending on what exactly your goal is, you'll likely have to do more than that, but starting with TArray as a base should be fine.
As an aside, I currently use this to good effect in my current project.
answered Apr 16 '16 at 06:17 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here