For Each Loop - Actor Has Tags

Hi All

I know this is simple, but can not figure it out.

Trying to setup an array with targets that have a set TAG. But it is a no go.

Script

Target With TAG

With Regards

That’s a component tag. Try Component Has Tag instead. Component Has Tag | Unreal Engine Documentation

Hi Dmitri

Same result, nothing. I can bypass it for now. Not sure why it does not work for me.

Thank you for the reply.

Regards

Not sure what your use case is for this, but your script works as long as you use actor tags.

I placed a few actors in the level with various actor tags, did a get all actors of class, then looped through them and printed all those that had an actor tag of BOB.

If you have specific components on your actor that you want to check, then do a “Get Components By Tag” and specify which component class and which tag you’re looking for. At that point in you will get an array of them which you can use.

Based off your code though, I’d say just use actor tags instead, that’s what you’re looking for. Not component tags.

If I get it right, you’re supposed to add actor with the BOB tag to the new array. Instead, you’re setting the new array to be the exact same array that you get with the Get Actors With Tag node. It should look look this:

1 Like

Hey,

I should have been more clear. Unreal has Actor tags and Component tags. You probably want actor tags. You can set them by opening the actor blueprint, going to Class Defaults, and adding the tags in the Actor category (you’ll have to expand the bottom of the Actor category to see it). Then you’ll be able to call GetAllActorsWithTag.
In addition, you’re resetting the same array variable to the array of all target points you found with each iteration. I’m not sure of what you’re trying to do, but I guess that wasn’t it. You’ll want to add individual target point references with each iteration instead of resetting the entire array.
Most importantly, you’ve created an infinite recursive event in Check.
I added an image with what I’m assuming you were going for.

264201-tags.png

Hi

What I am trying to do, is setup different Targets for Different AI to Patrol to (Random Tag Points) Example, Security only need to go to a certain 10 targets, citizens can go to all, etc etc

As per my image above, I have tagged the Target points (bob was just another I put in to test).

So when getting all actors with Tags, it will picj up all my targets and any other actor that has that TAG?

With the example above, it has been modified, but it is set up do drop a random “Chest” for pickup by the player. So it should loop forever.

I will look into what you have done and see if I can get it to work.

Regards