Because of the way TArray has been optimized, the order of the array should not be trusted, nor assumed, unless you sort it directly and intentionally.
if you want to force a specific order you should:
- create a sort for the array based on something about each element (How to sort an array? - #3 by ClockworkOcean) (in C++ you could define a sort predicate, but that would require defining the object type in C++ to be absolutely relevant)
- have the “collection of elements” be a struct (though this would require knowing the maximum amount in advance)
- having each “element” being a different reference on a given object, but this has similar limitations to the previous
even with or without a sort to get a specific element of an array you would still want to search, because if one of these elements gets removed somehow, or re-arranged (sometimes when the array is asked to expand all elements of the array are copied, and sometimes the order of the copies does not preserve the previous order)
we are also talking about an array of pointers which should not be manually manipulated as it could break GC, or cause loss of reference count resulting in early GC, and the Index definitely should not be manually entered per node (you set at index 0 shown in the screen shot). using Set()
on integral types (int, float, bool, enum) is fine (assuming the change is rational to begin with)
the order of instantiation of objects of Actors can not be guaranteed nor enforced (without modifying the engine’s core serialization system) the order your Spawners get instantiated, and start functioning might be different from run to run.
how are you “passing the whole array”? how soon after modifying the array are you passing it? try looping through the array to output like their names both before the pass (in the spawner), and after (in the receiver).
there is also the consideration that for some arrays based on optimizations for “data packing”, and expected interactions; the array might actually have more slots then the number of elements in it (for example an array of int32 with 1 element might be allocated with 4 indexes available but only the first one is used), this should be hidden away behind checking the size. we should kind of assume that the order elements are added to the array is the order they will be, but that is not always the case.