Is it possible to create GameplayTags inside the cpp? If so, how I can create them instead of relying on making CSV file and importing the tags to the GameplayTag DataTable?
Got "GameplayTags", added to PublicDependencyModuleNames inside my Build.cs. And my own class for GameplayTags.
class MY_API UCndSys_GameplayTags : public UObject
I even got this function set up, to simplify this.
I think you might’ve misunderstood the functionality behind the macros you’re using, because (reasons here, suggestion later):
UE_DEFINE_GAMEPLAY_TAG’s first argument is supposed to be the name of the generated tag variable, not a string
UE_DECLARE_GAMEPLAY_TAG_EXTERN is supposed to be used to expose the tag defined in a cpp to other code, macros like these are intended to be used in headers; using it right next to UE_DEFINE… doesn’t make sense
(assuming this even compiles) invoking these macros in the function will just create some local variables which won’t be accessible anywhere else, the only benefit you implicitly get is AddNativeGameplayTag which is called in FNativeGameplayTag’s constructor (which you invoke through the UE_DEFINE… macro)
Either way, here is a suggestion that should fit your use case:
Create a header+cpp with gameplay tag declarations+definitions, preferably in a namespace, for example:
These will automatically register the tags with the provided string names (second DEFINE argument), and any source file with #include "CndSys_GameplayTags.h" will be able to access them using the provided variable names (the first argument), for example: