Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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!

Product Version: UE 4.12
more ▼

asked Sep 07 '16 at 10:05 PM in Blueprint Scripting

avatar image

Andras D Ormos
18 3 6 7

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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.

more ▼

answered Sep 08 '16 at 02:04 PM

avatar image

48 11 9 14

avatar image Andras D Ormos Sep 08 '16 at 03:26 PM

Thanks very much! Maybe a screenshot would be a huge help. I'm not sure what you mean by making actor reference arrays.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question