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!
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.
Thanks very much! Maybe a screenshot would be a huge help. I’m not sure what you mean by making actor reference arrays.