Array available in all Blueprints

Hello, I have an array composed of 6 actors. I need to be able to invoke that array (variable) from any blueprint in the game. Right now I have that variable in the Level Blueprint, but no other BP see it. I try to create it in a Custom Game Instance Blueprint, but it doesn´t seems to work. I´d really appreciate if somebody can give me a hint, I don´t know where else to find for information.

Thanks!

Game mode
game state

google and read about those objects.

Thank you for the hint, CriErr, I´m on it now!

GameInstance should have worked too though, what problem were you getting?

, lets say I have 4 actors in my game which I want to combine into a (global) array. So in GameInstance, I create 4 actor variables referencing each ball, then I create a Make Array node which I connect to the first ball variable. When I try to connect the second actor, it says: “Ball 2 blueprint is not compatible with Ball 1 Blueprint reference”. I´m sorry, I know the issue must be a very basic one… Thanks!

They are all different blueprint classes are they? You can’t have an array of actors that are different types, they all must be the same.

One thing you could do is create an array of actors, by adding a variable, choosing actor reference as it’s type, and then making it an array. You can then drag it into the event graph, set it, and use a make array node again. This way you can add any actor to the array, only they will be stored as actor references not as Ball2 blueprint or whatever, so you’d have to cast it to do anything with it. But it may work, depending on why you are actually doing what you’re doing

Or, you could make a new struct in the content browser, make variables in it, each the type of your different ball blueprints, and then add that struct as variable in gameinstance and set it using make struct. This way you wouldn’t have to cast them, and you can access them anywhere by getting the struct from gameinstance

Thank you so very much for your kind answer, , it was really clear, and it helps me a lot.

In your first scenario, I already define variables in GameInstance which I later use in the game, no problem with that, but I never use a variable in the Event Graph tab. What module I suppose to conect it to? (Can´t choose “Event begin play”)

In the second scenario, if I use a structure (I didn´t even knew that, so thanks for that too!), I won´t be able to treat it as an array, right? I mean, deleting items dinamically during game play (suppose eventually some balls can get killed in the game)

I found out that “Event Init” seems to trigger the make array node in the Custom Game Instance… is this the best option, in terms of performance & memory, to create an array available through the entire game? Thanks!

Yes, Init is right, sorry, I didn’t mention that.
And yes, if you use a struct, it wouldn’t be like an array in that sense, though you could do things like setting one of the ball references to null, which would be like deleting an array element, though it sort of depends on how you you using the array if that would work, which isn’t clear to me.

Also, by using an array of actor references like this, you will have to keep the different blueprints at specific indexes so you can cast them correctly. For example, ball1 is always at index 0, ball2 always at index 1. Again, whether that could be an issue or not depends on how you use the array.

I’d say it is a good option in terms of performance, it’s a small array, and you need persistent references.

Thanks again for your time and patience, , I´m extremely grateful for your help