Download

UE4.24 - How to Find Actor with Tag, filter another tag and choose 1 actor? imag attached.

Hi, i´m having issues finding an actor,

A) i need to find tag “Enemy” from a group of actors (Actor Array 0)
B) After the previous selection, filter and find actors with a second tag “armor”, (Same actor BP type, Array 1)
C) Now, from this last list of actors, randomly choose 1 actor, not all actors, just 1.

I have been able to filter first tag with “Get all actors with tag”, but no idea, how to filter them to a second list, find actors with the second tag, and randomly choose 1.

Here is my BP pic, right now it finds the first tag, but if it doesn´t find the second tag, it continues to search… but sometimes takes forever to find an actor, or it finds the wrong one, and using “For each loop” was making it to choose all actors with tag “Armor” not 1, and there is no way to get actors with “Enemy” tag into an array and only from this list get all actors with the secondary tag, to finally choose one from these, no idea how to filter the second list by tag.

Please help! post your BP pic, thanks

This one causes it to select all actors with the second tag “armor”… while i only need 1 actor from that list, but still no way to choose only from the second tag, since no way to classify them, it has to test many times:

What are the values in your tag array? Your second picture looks like it would work fine, aside from the ‘Is Not Valid’ and ‘False’ pins feeding into the print and delay nodes, which create a bad and unnecessary loop. Those two pins shouldn’t be connected to anything. Also, the find and get nodes are redundant since the ‘Actor Has Tags node’ does the finding for you.

Thanks, the second pic, doesn´t work, because it gets all actors with the second tag, and i only need 1

Once 1 is selected, the systems deletes “armor” tag from that 1 actor, here is when the problem appears, once i click “enter” again, to choose another “armored” actor, “get all actors with tag” is still reading this actor previously chosen because it still must have the first “enemy” tag, but there is no way to filter it from this selection, into a second filter to only get all actors with tag “armor” from this selection, meaning, that 1 previously choosen actor, its also tested again, that´s why i need “not valid” and “fail” for now…because of choosen actors, since it wasn´t filtered its also questioned, if it has “armor” tag, even if it doesn´t, i did a graphic to explain better:

My newest testings:


This settup, finds all actors with tag, creates a list array (first filter), now it gets 1 of those actors, tests it, if it does have “armor” tag it continues, if it doesn´t have “armor” tag, it fails, causing the loop, but at least it is able to choose one, after X attempts, wich is problematic, because if at this point there is 100 “enemy” tags, but 1 “armor” it will test 100 times, until it finds it… 100 ticks. The reason why lenght -1 has a print string, was to discover this issue, it always counts 100, even if 50 where already choosen and Armor tag was deleated, but this issue was expected, since there is no way to make the “armor” filter form “Enemy” filter, this could have been easy to solve, if there where a node called “Get each actor with X tags”, that would allow to filter the selection not to all actors with 1 tag, but requesting several tags to make that choise.