Comparing an actor to a list of actors

Hi, i’m making a tree chopping system and would like to know how to compare the tree ive hit with a list of possible actors. If the tree mesh is in that list i would like to return a bool value.


Here is what im currently doing, but as stated, i’d like to compare it to a list.

Any help is appreciated!

Use tags, and check if “actor has tag” instead of comparing it with a list of actors, it should be more efficient and faster. If the actors of the list share the same parent you can add the tag to it and they will inherit it

1 Like

My problem is static meshes can’t have tags.

It sounds like you’re either looking for the ForEach node or the Contains function on Arrays.

Either way you’d create an array of static meshes, initialized with all the meshes you’re interested in (SM_Tree_01_Var1, etc). Once you have that you can either:

  1. Call ‘Contains’ to see if the Target->StaticMesh is one of the elements of the array.
  2. Manually do a ForEach over the array and see if it matches Target->StaticMesh.

Also, to Ares9323’s point: You wouldn’t add a tag to the static mesh. You’d add it to the actor that has the static mesh component. Then, instead of checking HitComponent->Target->StaticMesh you’d be checking HitActor->Tags (or HitComponent->Owner->Tags).

Option 1 is easier, option 2 allows for more flexible checking (like if certain trees can only be cutdown if you have a certain axe equipped).

2 Likes

Oh sorry, I didn’t pay too much attention at the screenshot and I didn’t read that you were comparing static meshes, the title said “comparing an actor to a list of actors” so I took for granted that it was an actor.

I agree with both the solutions provided by @MagForceSeven

1 Like