There must be something I'm missing with Structures.

Hi people.

I find myself having a problem with Structures, as in “cannot store values”. I will explain:

My game is divided into chapters, and has two inventories, so to speak. One stores the usable items (the Inventory), and the other stores the documents that you will find throughout the game (the Documents Collection). Both are stored in my Player Controller class, as you will switch characters but they will all have access to the same items.

The Inventory will be wiped out between chapters, so I only need an array for it. When you find an item in the level, it is stored in this array, then the array is passed to the relevant HUD widget in order for it to be able to show it and allow the player to see its description and examine it. This works perfectly.

The Documents Collection, however, will not be wiped out between chapters, as I want the player to be able to access any document he/she has found at any point in the game, regardless of chapter. For this, i am using an array of Structures (each Structure is composed by an array of Documents, so the Documents Collection would be like a 2-dimensional array). So, when the player finds a document in the level, I access the item in the array of Structures corresponding to the chapter I am in, then add the newly found Document to that element (which is an array of Documents), then pass the whole Documents Collection to the relevant HUD widget for it to display.

The thing is, when I add an element to the Documents Collection, it adds nothing. I have tried these two methods.

  1. Directly add the Document to the corresponding array.


  1. Set up a temporary array of Documents, add the Document to this array, then set this Array as the element of the Collection corresponding to the chapter I am in.


None of these methods work. I have an action binding which shows me a string for each element in the array of Documents corresponding to the chapter I am in, and it shows nothing. The curious thing is, both my Inventory HUD widget and my Documents HUD widget are set up so that they show a button per item that you have (so, if you don’t have any items, it shouldn’t show any buttons); if you click on it, then you access its details.

When I pick up a Document, the HUD shows a button (so there should be an item, it works in the exact same way as the Inventory and the Inventory works perfectly, the only difference is the Inventory being an array and the Documents being an array of arrays). If I click on the button, however, the editor crashes because it tries to access a null object.

I am a bit clueless. I don’t really want to create one array of Documents per chapter when I have Structures available. Does someone have any clue as to what might be happening? (For the record, I have tried every possible method of initializing the Documents Collection (the array of Structures): don’t initialize, create one element per chapter in the Default values, use “make array” nodes to set it up at Begin Play…)

Thanks in advance.

Its a long running bug. I’m excited for 4.7. Hopefully, we’ll see a fix for the notorious ‘Set Members in Struct’ for Struct contained inside of an Array JIRA UE-6451.

Thanks so much!! I also found a workaround in this thread:

I now have the following setup and it works.


Glad it’s working for you. I’m deliberately avoiding any C++ modifications. My Blueprint workaround was a Structure of Arrays. I simply encapsulate two or more Arrays of an individual Data-type into Virtual Structure with some fancy Labeling and Categories/Subcategories (ie: Structure|Array|Structname). I use macros to perform array operations (Add/Insert/Remove) on all arrays in the VStruct to maintain index alignment. The more arrays the more expensive. The trade off, update/modify Member with greater granularity flawlessly. I’d rather be able to update a Struct Members in Array of Structs.

That’s an interesting approach as well. Will keep that in mind for the future.