Ill be quick and to the point. There is no way in blueprint to have a string of a gameplay tag and drag out from the string to ‘get’ a tag by that name from the main list of tags (from project settings tag list).
Does anybody know how to accomplish this? Would be nice to just call a new node that has an input for string and outputs a tag struct and bool for if found or not. behind the scenes of it (c++) its just searching for a matching gameplay tag based on that input string, from the project setting existing tags, not a container.
Its odd that you can convert a tag name to string but not a string to tag.
Im not versed in C++ so its not something i know how to create.
First, it’s called “request gameplay tag”:" upd: oops, it was a custom function and i missed this fact during initial answer
Second, I use this function alot from c++, but never used it in blueprints as there you can define the tags directly. So i suggest you to doublecheck whether you really need it.
This is not popping up for me at all. Is that your own custom node that was made in C++?
I save a gameplay tag to my item database. On recreation its a string from the database that needs to be recreated as a tag but there currently isnt a way to do that. I had to create a datatable with the structure of a tag just so i could get a matching name and get that rows tag. Not very versatile since it requires me to make sure its always updated with any new tags ive added.
if you use Make Literal Gameplay Tag you can just choose which tag you want and it returns an FGameplayTag that you can use for queries. There’s also a Make Literal Gameplay Tag Container which does the same but for a container. Hope this helps!
Thanks a lot! I dabbled in random bits of code i could scour from the internet earlier today but had no luck, especially since i didnt know what it was supposed to look like, what was missing, what was right and wrong, etc haha.
I’ll mess around with this new code you pasted and see what i get!
Hmm, cant seem to get it to build in order to test. I’m seriously shooting in the dark though on where i place what snippet of code lol. I’m VERY inexperienced with the .h and .ccp files in visual studio.
At this point it would been hard to describe it in details. In short this code can be put literally anywhere, as long as you keep required parts intact and properly replace the other parts.
You can try to check something like this to get initial understanding
Moving forward but new error popped up, but this time for the cpp.
1>D:\MMO_Project_5.1\MMO_BMonline\Source\MMO\Private\MyBlueprintFunctionLibrary.cpp(9): error C2027: use of undefined type ‘UGameplayTagsManager’
1>D:\UnrealEngine-5.1.0-release\Engine\Source\Runtime\GameplayTags\Classes\GameplayTagContainer.h(212): note: see declaration of ‘UGameplayTagsManager’
1>D:\MMO_Project_5.1\MMO_BMonline\Source\MMO\Private\MyBlueprintFunctionLibrary.cpp(9): error C3861: ‘Get’: identifier not found
i think maybe im missing an include type of some sort of tag manager?
Here you can see, that the required header is #include "GameplayTagsManager.h"
which we probably missed.
Also probably you missing a module GameplayTags in your *.build.cs file. Add it to PublicDependecyModuleNames, so this part of file would look similar to this:
#pragma once
#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "GameplayTagContainer.h"
#include "ECRPythonHelpersLibrary.generated.h"
UCLASS()
class ECREDITORMODIFICATIONS_API UECRPythonHelpersLibrary : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintCallable, Category = "GameplayTags", meta = (ScriptMethod))
static FGameplayTag ConvertStringToGameplayTag(const FString& TagName);
};
.cpp:
#include "ECRPythonHelpersLibrary.h"
FGameplayTag UECRPythonHelpersLibrary::ConvertStringToGameplayTag(const FString& TagName)
{
// Get the GameplayTagsManager instance
FGameplayTag Tag = FGameplayTag::RequestGameplayTag(FName(*TagName));
// Optional: Check if the tag exists
if (!Tag.IsValid())
{
UE_LOG(LogTemp, Warning, TEXT("Invalid GameplayTag: %s"), *TagName);
}
return Tag;
}
Then, in Python (after adding tag records to Config/DefaultGameplayTags.ini, it won’t work with not yet existing tags): gameplay_tag = unreal.ECRPythonHelpersLibrary.convert_string_to_gameplay_tag(tag_str)
Also, if adding tag to container, don’t forget it’s not inplace operation, you want to assign result to variable: container = unreal.GameplayTagLibrary.add_gameplay_tag(container, tag)