How can I check for matching GameplayTags on other Actors in C++?

Hi community,

I’ve been trying to implement GameplayTags into my project but am having some troubles working with it in C++.
I am casting a LineTrace from my player into the world and am currently simply checking if the hit Actor (Hitobject) has a specific Actor tag with:

if(HitObject->ActorHasTag("PickUp")
    // Do something

How can I build around the same logic using GameplayTags?
I can’t call “HasMatchingGameplayTag” on the Actor and I am also finding no other way to get the GameplayTagContainer that is on the HitObject.

Any help is much appreciated. Thanks in advance!

This is because there is no GameplayTagContainer built into the Actor class. The tag that you’re using there is just a list of strings from a tagging system that predates GameplayTags.

You have a few options: 1) Implement the IGameplayTagAssetInterface interface and use that to get/check the tags that you’re interested in, 2) Add gameplay tags to a custom AActor class and use that for all your actors (but this can be tough to apply to all actor types), 3) create a custom component that you can place on any actor.

1 Like