Download

Creating a dynamic array of objects?

Currently, I am attempting to create a dynamically sized array of objects from a specific Blueprint class. From my previous experiences with Java, I figured I could create an array of references and set an index to a new object when needed, although I’m not entirely sure as to how I can approach this issue. I tried to use a temporary object, and the array simply fills each element with that same object over and over. Any alternatives available?

Not entirely sure what you are trying to achieve here but you should be able to do a loop and add objects into your array quite easily. Mind posting up a pic of your blueprint so far?

Like ZoltanJr I’m not sure where the problem is, and my answer might seem obvious, but have you tried to use the “Add” node to your array on each element?

You can either add each object to an array (make a variable of the type ‘your object’ - then turn it into an array in the usual way) or just use a get all actors of class node.

Why not just set up an empty class array variable and have whatever it is you are calling Add or AddUnique to your array. In the example below I used a for loop to add all the values of my default loadout to my current load out but the concept is the same. Your function will trigger an add, the add variable will be the dynamic part

3d692b6b39f85c343fa4734044281880c03329ee.png