x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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

Product Version: UE 4.9
Tags:
more ▼

asked Apr 15 '16 at 11:52 PM in C++ Programming

avatar image

joelComberiati
112 26 22 28

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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[1] holds weapons, [2] 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.

more ▼

answered Apr 16 '16 at 06:17 AM

avatar image

KingCole32
180 9 9 12

avatar image joelComberiati Apr 16 '16 at 07:14 AM

Thanks for the info, good to know

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question