How do I add an element to an array?

@mikepurvis

Thanks for the quick reply :slight_smile:

Sure, here is what I have:

I have a struct called “StaffUnitDef” that looks like this:

A blueprint component, called “MotherbaseBPC”, has an array variable of that struct which is prepopulated with various units.
It has functions for returning the Staff limit and other values (which works. Reading from the array is no problem).
It also has a function for adding a staff member to a specific unit.

This component is attached to a GameState object:

2d293bbc12f1cd5e46d0a0654f26898379754b78.jpeg

So far the setup.
Now I try to access/modify the array from another place. For testing purposes i chose the level blueprint.
As I try to modify the “Medical” team by adding a staff member, this is what happens on key presses:

X - a “100” is logged, correctly reading the staff limit for the medical team
C - a “0” is logged, correctly reading the initial staff size of the empty team.
M - an “added” is logged, showing that the code ran indeed.
C (again) - a “0” is logged, although the array is expected to have a new element added.

5931537ea6cc2f64cef86e20357ce62afa3b3a9b.jpeg

If you need more/better screenshots, let me know :slight_smile: