Get an array of all instance of a structure type

Hi there,

I spent a lot of time on this problem without find solution…

I have a structure (made in asset manager) and a lot of children variable of this structure, I want to get all variable of this structure type in an array (for apply the same processing with a ForEachLoop) but I can`t find the way for doing that…

Someone has an idea ?

Many thanks !!!

  • You can Make Array by dragging the array pin off the Loop node. Then plug in your structs.
  • Alternatively, make another Struct var, turn it into an array and Add/Set the structs as elements.

Not sure if it still persists in 4.19 but there was a small bug where the Make Array with a struct plugged into a wildcard array pin did not propagate its type at all - you might notice that the loop’s Array Element pin remains grey after plugging everything in.

If that happens, unplug the make array from the loop and plug it back it.

edit: it’s present in 4.19, as seen below:

Hi Everyone,

Thanks a lot for your detailed answer ! Your second solution is great for reuse the selection.

I was looking for a function that allows to get all the elements as there are for the actors of the same class but I have the impression that it does not exist with blueprints…

Thanks again,

Not sure if I understood you right but it’s unlikely that it cannot be done. Consider describing it in a bit more detail if you still need help.

If you wish to iterate through a bunch of actors and add their structs to an array - it can be done easily enough.

Get All Actors Of Class node will give you an array of actors, loop → get struct → add to a struct array.

No need to manually add them one by one or plug in a dozen of elements to Make Array

Good luck!

Indeed, sorry it was not very clear, the goal is to not manually add the elements, I was looking for something like Get All Structure Of Type.
I just create a “parent” structure in my asset and use “child” of this structure like pure variable in my game instance for realise some math function, it may not be the best way to proceed, I probably do not have the logic of the engine and blueprint…
So I think I can’t use Get All Actors Of Class node (but I’m curious about your Get Struct node, are you sure this node exist ?).
In my case, I think the two ways to proceed:
-Make a “container actor” for child struct and use him for getting all struct with this Get struc node
-Create an array of struct and use Add Element method for create a new child structure.

I thank you very much for your help and your time Everynone !

Have an array variable in your Game Instance, and then everywhere that you create an instance of the struct, Add Unique to that array. Anytime you delete one of the struct instances, remove its reference from the Array. Then you’ll always have an up to date list of all that Struct’s instances available to you.