Adding attribute sets dynamically / in blueprints?

After pouring over the internet for this, it appears that the only way to actually define attribute sets is declaratively in c++? Is there no way to do this from within blueprints?

What if i wanted to dynamically generate these attributes from a list as part of the construction script? Is my only option to go in and manually add the attributes into the c++ code or is there a way to define those values using an array or data table in blueprints so that it pulls from that and generates the attribute sets that way?

Hey there @BenVolo! I have limited experience with the new GAS stuff, but I’ve noticed a large portion of it only has C++ accessors, and in this case you’re correct. Gameplay Attribute sets are (by documentation at least) only capable to be accessed from C++, that said writing a C++ constructor/passer for it exposed to BP you could probably make a quick interface for it. I’ll be doing a bit more digging. I know you’ve already seen the docs, but I’m gonna drop them here as well for anyone else coming across this thread. I’ll let you know if I come across any contradictory information!

1 Like

Epic really need to do a proper tutorial series on GAS and how it all breaks down. Actual documentation on this is scarce and the main info you get from official sources is just ripped from presentations or workshops which is pretty unacceptable considering Epic themselves have been using GAS internally for years now.

I’m not super familiar with c++ but couldn’t you do something like this…?


string stats[4] = {"Health", "Stamina", "Attack", "Defense"}; //pull this from blueprints somehow. construction script?

for(int x : stats) {
UPROPERTY(EditAnywhere, BlueprintReadOnly)
FGameplayAttributeData ToVariableName(stats[x]);
}

But i have no idea if there is actually a way to use a string as a variable name in c++. And if you’re pulling an array from blueprints, would you want to do that in the construction script?

as in like:


UPROPERTY(EditAnywhere, BlueprintReadWrite)
TArray<FString> DynamicInputStats;

or are all of the uproperties defined at once and there is no way to change them at runtime?

I agree there needs to be more learning content dedicated to GAS, and more of the system needs to be exposed to BPs. C++ does much of it’s work at compile time so new full variables during runtime is likely not something we can do in the current structure. If this were Python or Ruby we’d be able to do that on the fly.

Sorry admittedly I’m out of my wheel house there, my normal recommendation is if possible to use the entirety of GAS in C++ to avoid trying to cross the blueprint line, which I know isn’t super feasible for all projects. I tried to find some reference since I know there have been others translating attributes back and forth but they were using a dynamic array of structs, but I can’t seem to find the post.

Hi there,

Are you familiar with this plugin for UE5?

You may want to contact the developer and check how he can help you.

no i wasn’t aware of it, thank you for the recommendation. I’ll check it out.