Gameplay Tags versus FName

What are some of the best benefits of Gameplay tags?

In the past I’ve always used FName as a very flexible way to define modular things.

I might have a map of FName to some definition objects, or I might add FNames as tags to some objects in my world.

I’m seeing in Lyra they use Gameplay tags a ton in ways that I normally use FName. I find Gameplay tags a bit harder to work with and slight overkill for some of the things they use, but maybe I just don’t understand gameplay tags.

For example with FName, it’s really easy to use as a key in a Map for quick lookup of things by name. Also with Gameplay tags it’s hard to arbitrarily add new tags, and its harder to work with them in C++ since there’s some work involved in defining them. With an FName I can just write it in the code directly. As I understand Unreal turns FNames into integers under the hood anyway so it’s like working with highly optimized strings.

Gameplay tags can be cool as like a property bag of booleans, or in place of Reflection and object oriented programming. Like normally I might say, is this object of class Gun.
But if I don’t have access to a class I can check if it’s gameplay tag matches the query of Inventory.Equippable.Gun.

In Lyra I see they use gameplay tags basically everywhere, like the input system, the UI attachment locations, defining ability types. What’s the benefit of using a gameplay tag versus an FName, for example, when using it in the input system?

A GameplayTag is an FName on steroids. It’s basically the same exact thing as far as C++ is concerned (cost, performance, etc).

You can write GameplayTags over the network.

Think of GameplayTags like an FName registry. All the same performance as FNames, but you organize and coordinate the names of the tags, and then you can use them anywhere you want, including (quite easily) over the network.

1 Like

Oh that’s pretty helpful. So I should think of Gameplay tags as FNames with even more extensions.

I see the only data in an FGameplayTag is an FName so under the hood it can work as an FName for most things, like keying into a map.

Right.

The two are very similar. FName is easier to hack together in code, but impossible to organize otherwise. So if you really require zero organization or ability to reference the name externally, then an FName is fine.

Otherwise, you probably want to use a Gameplay Tag rather than an FName. It’s a tiny bit more work to set up initially, but it has vastly superior organization and external referencing functionality.