Download

Activate an actor once all bools in an instance editable array are true? [Solved]

Hi all,

I’ve started work on my second game and I’m still playing with a bunch of ideas. One idea I wanted to try was something I thought would be simple, but is giving me some trouble.

Basically, I have some pillars that activate when the player approaches. At BeginPlay each pillar adds their “IsActive” bool value to an array in an instance of a tracking BP placed in the level. They are updated in the array each time the pillar’s “IsActive” state changes.

I’ve set it up so I can theoretically add as many of these pillars as I want. As long as I assign the correct instanced actor value of the tracking BP for each pillar, I’m able to know which of the pillars are activated, and which aren’t.

So I have the tacking BP that keeps that track of which pillars are set to “true” or “false” but I don’t actually know what to do when all the bools in the array are set to true.

Since this relies on specific instances over hard coded values I’m not really sure where to proceed from here. If this was a one-time set up I could make the thing go through each array listing and check its value, but since the number of listings in an array can change depending on how many pillars I want to use I need it to be more flexible than that.

Is there an easy way to check how many listings in an array are set to true, compare it to the total number of items in the array and then activate another actor if they match?

I’ve tested the state tracking pretty extensively and it works, so that’s not a problem. I just need to know how to get the tracking BP to realize that everything in the array is set to true and I can take it from there.

I appreciate any help I can get!

Cheers,
-Axel

Why not just write the pillar BP so it activates when the player is near?

towers.gif

Ah, sorry, slightly misread that. So you want to do something when they’re all activated?

Then the BP looks like this:

And you have a central monitor BP that looks like this:


more-pillars.gif

( It says YEAH in the last frame, but you can’t see it :wink: )

Increment an int when a pillar is set to true, subtract when false. Then array length == int -> activate other item.

This worked! It’s such a simple solution I feel a little silly I didn’t think about it.

Much appreciated! I can move on with my life now.

Yeah, it’s often easier to distribute the logic in lesser actors, then you often don’t need that complicated controller stuff… :slight_smile: