How to make an array of all Geometry Collection in a blueprint?

I want to add all geometry collections I have in a blueprint to an array, how do I do that? I want to know which array type is correct and how to add each Geometry collection to the array.
What I am trying to do is make an array that holds all the geometry collections from chaos fracture, and the array updates by removing which have been destroyed, until the player destroys everything causing the exit to open when the array is empty.

did you try get all actors of class then just save as array or add tag to them and use that. this is not cheap if you have lot of GC in level

Hey there @LonelyBox! There are lots of possibilities depending on if these geometry collections are ever different or procedurally generated in some way. Assuming they aren’t just staticly added before compile time, you could have them added to the array when created, though you can also find all of them under the actor by using Get Components by Class and just Set the array to it on creation or whenever you want to reboot them.

To remove the elements once they are broken you can use the On Chaos Break event (which you may need to bind to if you’re making these at runtime instead of hardcode as I demonstrate here), then pass a reference to a Remove Item node.

This example uses the event itself on an example component, but you could also just subscribe to the events for all of the components in the Get All GeoCol custom event if you were piecing these together at runtime. I use Component Primitive for the array here, which differs from your original a bit.

This doesn’t scale infinitely though, setting an array of many items is fine for sometimes but if you need to do this often you’ll need to be a bit more meticulous. It might even be more prudent to subscribe to those items with a manager in some instances, but chaos itself is also rather expensive so it’s best to keep the scope smaller in these instances.

(post deleted by author)

I was planning to do that, but wanted to know if there were better methods to handle something like that. Thanks for the answer!

The geometry collections are small, but will be a good amount of them(maybe 100 to 200). Its going to just be one array for of these geometry collections for the game, so will it be too expensive? If it becomes expensive to do, is there something I could do to optimize?

Ahhh I misunderstood your intent. So you are trying to have an external class manage them not one inside it’s own class as components. This changes everything. You would have to use Get Actor of Class and actors is the primitive. Since it would be a manager type pattern, you would need to bind their break events or set up another custom method of listening for them.

100 to 200 simulating all at once? That might be rather heavy depending on how you’re intending to operate. You would also be updating the array frequently, which could be bad depending on a number of factors. I would recommend managing their pieces post break with Fields, as they are the best means of handling the individual pieces and their performance optimizations with sleeping and killing them when conditions are met.

What is your use case for the array? If I understand the bigger picture I could recommend a better design pattern.