Can't get the "Component Has Tags" node to work properly

Hi all,

I’ll start with the elephants in the room: I did not misspell the tags, and I know that Actor Tags and Component Tags are different.

Now, the issue I have is that I can’t get the node “Component has tags” to identify/match the tag it has to. I’ve been struggling with it for days now. I need it for a basic A.I. function, where the A.I. needs to find a target, and confirm whether it is hostile or friendly. I’ve first set it up following a tutorial which covered how to find a target (and that part alone works). I’m trying to add a friend/foe part to it using tags, but whatever I do, it breaks the function.

I managed to get “Component Has Tags” to work when I used “Break Hit Result” and connected the “Hit Component” output through a “For Each Loop With Break” node into “Component Has Tags” but it wouldn’t work when I feed a Name variable into “Component Has Tags” that has the same tag, spelled right. So to sum it up, when I have the engine match the component tag with an exact match it fails, but when I have the engine get the component’s tag to later compare it with itself, it succeeds.

Please see screenshots attached. If you need any more details, let me know.

Thank you in advance.

I’ve finally fixed it; well, found a workaround anyway. Instead of messing with “Component Has Tags,” we can use Does Equal To (==). Get hit component’s tag, feed it into a “For Each Loop With Break,” then have “Does Equal To” compare the result with the desired name variable. Please see screenshot for illustration.

Sportbil, thanks for trying to help by the way. I’m sure your comment will help someone, somewhere.

If anyone reading this can tell why didn’t the original method work, please let me know. Thank you in advance.

same problem here (v4.27)

I have a collision box (part of an actor) with a tag

as I hit that component (LineTraceByChannel), i can get it’s object reference

but “hastag” returns false

and “get component tags” return an empty array

There are several versions of tags, f.e. actor tags and component tags, and they are in different places and you have to look up them differently.

Tis video explains it pretty well:

So make sure, that you are searching for the correct tag and that your tag is placed in the correct place :slight_smile:

usualy I first watch his videos

then I come here asking for the missing bits or things that dont work :slight_smile:

Have tested it the way he explained it in his video, on a cube, that has both an actor tag and a component tag on the cube mesh itself. In my try, it worked in 4.26 and 4.27:

yeah I made it work, suddenly the has tag function worked

while trying to get all the tags gives an empty array

2 Likes