How can i get number of all actors of certain color/material?

I need a counter for all actors with specific materials and to display "You won " when all actor’s colors are red.

When an actor is hit by the player it’s colour is changed to red and when hit by another actor its changes to yellow. I need a counter to display the number of actors who are not yet red. I assume it can be done by creating a variable with the hardcoded number of all actors and then doing -1 when painted by the player and +1 when by another actor but maybe there are some better ways?

1 Like

No, that’s basically it. Except I think you might have a problem if I repeatedly hit one actor?

Anyway, a better way, is to do it with blueprints, instead of actors. That way, you get to set a boolean when they are the right colour.

All you have to do is count how many are set. No more comparing materials etc.

Maybe you have some useful links about a way to do it using blueprints, instead of actors or you could show a simple example? Thank you in advance!

So I have a widget with a text box

I make a ‘widget manager’ blueprint, and put it in the level

I make a blueprint, and put 3 in the level ( the widget manager variable is instance editable )

( I used a line trace, you can use overlap or hit or … )

I tell all my blueprints about the manager

Now I can play

red

1 Like

That’s it! Thanks!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.