How to set a variable from a random actor?

Hello.

I have 5 Class_Blueprints added to my scene named “BALL1_BP, BALL2_BP…etc”. Each of which has a public variable named “ActiveDD”
I’ve added them (their references) to an array from which i get a random reference, as shown in the attached image.

What I can’t figure out is how can I set the “ActiveDD” variable of the selected (by the random operator) Actor to true.
I’ve tried using “cast to” but the problem is that each cast to requests a different random actor (class blueprint) and lead to problems such as more than 1 actors having their variable changed, or sometimes none.

One way is to have multiple “cast to” nodes. plug the “cast failed” pin from Ball1_BP into the next “cast to” and so on.

Al of these balls Bp should be instanced actors of the same Bp.
If for any reason each ball must have different properties, you should apply the settings on a construction script instead of creating a different Blueprint class for each ball. That way casting any ball to the correct Bp class would never fail and is also the intended engine workflow anyway.

Thanks for your quick replies.
I had tried the cast to method (as seen in the image below), but since each cast to requests a different random actor (array position) there were cases that either a few actors were cast or none.


Yes, the BPs must be different so I’ll try the construction script method.

Thanks again

I concluded to this.


I don’t know if it’s efficient but it seems to work.