Download

Basic communicate between actors

i have problem with communicate from an actor to other actors , i have attached a picture , could you guys tell me how you make something like this with blueprint ? all of them are from a same class blueprint .
and i want to know how can i send message from one of them to others to changing their colors . main problem is in step 3 after clicking on another actor to active that how can i change previous active actor color in step 2 to back green again ?

5e8f0aabe78f111115299116aa0dc67255849e55.jpeg

thanks

well, the ugly way (fmpov) would be to get all actors of class, select your fieldclassBP and change
colors within a foreach loop, in case you clicked one.

A proper way would be, you create a Blueprint (f.e. AFieldActorContainer) which contains an array of your FieldActors.

You spawn such a Container into the world and within its class it spawns your 3x3 field actor grid. Or you just make them components of the Container BP.

The advantage you have now, is that the container class knows about all of those fields.
And each field knows its parent (the container) in case they are components, if not you can inject the parent to your actors via a function.

So each field will have a click event function. And if it triggers the field sends a message to its parent, telling him that something needs to be done and
that is coloring all the fields inside the array to green.

You can even set up an Input Event (Keypress “R”) inside the container and iterate over the array again to set the color back to blue.

thanks a lot Wallhalla , i think using AFieldActorContainer is better way for me, i will check that,.

youre welcome :wink: