How to count the number of actors in a scene, but filter them with a certain criteria?
For example I have 20 enemies on my map and they are all wearing differently colored hats. This color is stored in a variable in each of them. Now let's say, I wanna count the number of enemies wearing red hats, how would I be able to do that?
With my limited knowledge of arrays I can get the number of actors from class, but I don't know how to filter based on a criteria that is stored within these actors themselves. The only filtering I could find is the "actor has tag" node, but that what I would need is value within variable kinda thing.
Hope someone knows the answer, Thanks!
asked Sep 07 '16 at 10:05 PM in Blueprint Scripting
Andras D Ormos
I'll see what I can do without Unreal Engine in front of me.
In circumstances like this, you can make actor reference arrays for every actor with a certain colored hats. (One for red, one for blue, etc.)
Once spawning in, you can cast to the actor and get the static or skeletal mesh that the hat is. Once that is done, you can have a branch with the condition being if the static or skeletal mesh equals red hat, blue hat, etc, then add the actor to the appropriate array using the cast nodes return value.
When you want to get the number of enemies with a certain colored hat, you can use an length node on the certain array.
Hopefully that wasn't confusing. When I actually have a computer in front of me, I'll post screenshots if you need it.
answered Sep 08 '16 at 02:04 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here