Is There a Way to Attach Related Actors?

Is there a way to attach related actors to an array or a map, each attached to a single element, and when one actor is selected by the mouse, all the other related actors would also be selected? And when an element of the array is altered, a corresponding change will also happen to the related single actor?

That sounds like a good way to go about it, yes. Each actor in the array needs to be able to find and access the array they’re in, and I like to put global things like that in my custom GameInstance class, because any actor can access that with a simple Get GameInstance node followed by a Cast to your own class of it that you created, and then all your GI class’s variables are available in the reference provided by that cast.

So for instance when one actor gets selected, then along with selecting him you can grab that array from the game instance and loop over all the other actors in that array and tell them to select as well.

And anywhere you perform an operation that changes the array, you can take a similar approach to signal the other actors in it.

Now, I would like you to consider an alternative, using Event Dispatchers.
An event dispatcher can call a function that only actors which have registered the event will receive.

So lets say you Call the Select event. The targeted actor will have already registered to receive the Select event, so it will run it, but also any other actors which registered it will fire their Select events.
Registering for a dispatched event would be done on the actor’s creation or whatever adds them to your imaginary list of those which should be affected. Clicking on one could certainly add them. I’m not sure how to unregister them though if you want to not have them receive the event anymore. It’s basically broadcast to all actors that have registered for it, in the world.

You can manage it this way or you can use the array method, either one works.

And there’s probably lots of other good ways too

Thank you.

I think the event dispatchers would be too universal, there are more than one array of actors and so far if I use event dispatchers on the intended class of actors, all the arrays would be affected by the event instead of just one array of multiple actors. Unless of course there are other approaches related to event dispatchers that can avoid this, only they have currently eluded me.

And I am still in the progress of learning blueprint, I am really a noob, so Ill have to ask you to be more specific about the GameInstance option, since I dont really know how to create and customize a GameInstance in blueprint, having found no relevant articles in official documents about GL.

Thank you again for taking your time.

It is like extending any other blueprint class. You right click an empty space in the content browser and in the menu that pops up choose create blueprint (I think thats what its called) and you’ll be presented with a list of base classes you can base your blueprint class off of. Pick the Gameinstance one and then you will have your own gameinstance class with its own variables and code.
Then you will need your own gamemode too so you can choose it in your level or project settings. Game mode can set which game instance class to use.

Game instance is a nice way to keep track of global values and have them stick around between levels during the entire game session.

Game modes tell the level or game which playercontroller, pawn, Game state, Game instance class to use. These things together can make the game act differently and have different rules.

Also i didnt mean for event dispatchers to use arrays. I meant that instead of arrays you would have any actors that should be treated as part of the group register for the dispatched event.

But I think arrays are a good way to do it.

In the unreal website documents there is a section called Gameplay Framework which explains what all the game mode and game instance etc are for.

Yeah, I got what you meant. I was wondering if event dispatchers could achieve the effect of independent multiple arrays of the very same class of actors, so I meant in my reply an imaginary, virtual manner of array that is assembled by the event dispatchers.

Thanks.

Thank you very much.

And your suggestions have been very helpful, thanks again. I am starting to get the hang of it.

Okay yeah thats what i meant too