How to read material on all actors in array

Hi all. I’m trying to read, in realtime, how many actors still have a starting material. The material will change when these actors hit another actor, so this number should reduce each time. I’m not quite getting it - and I think I’m not understanding something about the array and the way it works. If I run the code below, it shows the number once at the start of the level. I want this number to update each time the value changes - ie: each time the actor is hit. If I remove the ‘do once’ node, the number decreases far beyond zero. I would appreciate any help you can give me - Thank you in advance.

You’re checking it 60 times (or more!) every second - that’s Tick. It counts all the time but Prints once because Do Once never Resets.

Perhaps it would make more sense (and be orders of magnitude more performant) to check how many actors there are to start with, and only count when bad things happen do them:

  • consider this is the actor getting hit:

  • it turns Grey if it was not Grey before and calls a dispatcher

We can count Greys like so:


You can also clamp values to prevent them from exceeding ranges:

image

But that would not be needed in this very instance as Grey actors do not call the dispatcher when they’re hit, no counting is necessary here.

Would that work for you?

1 Like

How to read material on all actors in array

I can’t see you attempt to perform any material operations, my assumption is that you’re counting stuff. Do tell if I’m mistaken because you can absolutely count / compare materials:

But it seems redundant at a glance. Hope I’m not wrong.

1 Like