Issue with tags

Hello people,

i am new to Unreal Engine 4. I have a problem with Tags. How can i figure out if an actor has a tag or not?
I gave an actor a new component tag, added this to a StaticMeshActor due to the details palette. (Category tags → component tags)
Now I tried to use “ActorHasTag(…)” in my code, but always the result was false. If i am trying to access the tags directly by Tags[0], i always get an AccessViolation. I am very sure, that i have the right Actor, because I can log his correct name.

What am i doing wrong?

MfG Artery

PS: Worked a lot with Unity in the past, maybe i got a wrong mind about tags in UE4?

There are 2 different types of tags you mention here, actor tags and component tags. when using ActorHasTag, this is looking at the array in the actor class defaults. if you want to find a component by a tag you can use:

TArray<UActorComponent> MyActor->GetComponentsByTag( FName TagName)

If you want to find out if an actor has a tag, you are correct in using ActorHasTag(). you can check actor tags by opening the actor blueprint and selecting class defaults in the toolbar, and scroll down or search in the details panel for tags

Access violation is because you are trying to access a empty array, try using some error checking like checking the size of the array first using Array.Num

I can elaborate more if you need?

Hope this helps