Hi,
I have attacked a problem from several different angles and now I think I have emptied my toolbox with good tools for this issue as I have hit problems with the unreal header tool every time.
I’m going to do a attribute system for a character, and I want to be able to access it nicely from blueprint.
I want to have attributes of different types, and support them all without duplicating lots of code.
My first idea was to make a FAttribute struct that is templated and have a few members variables like: OriginalValue and BuffedValue that should be accessible from blueprints.
However, I noticed that you can’t declare USTRUCT as a template. I tried to modify unreal header tools to support my FAttribute, but I noticed that I don’t have deep enough knowledge to get this fully working.
Next I tried to generate the classes with macros (ugly, I know), but then I noticed that the unreal header tools doesn’t support other than the hardcoded macros that exists.
Last angle of attack was to make a enum for each attribute, and then add a include file (IntAttributes.h) containing:
INT_ATTRIBUTE( mStrength, IA_Strength )
INT_ATTRIBUTE( mDexterity, IA_Dexterity )
and then in the header file of my character do:
enum EIntAttribute
{
#define INT_ATTRIBUTE( ATTR, VAL ) ATTR,
#include "IntAttributes.h"
#undef INT_ATTRIBUTE
};
And then my plan was to do a map in the .cpp-file the same way. And then access the attributes with getter and setters through blueprint. But here I noticed that you needed to declare the enum as a UENUM to be able to expose it to blueprint and then it didn’t read the #includes properly to generate the headers properly.
Is there any plan to extend the header-tool to support any of these patterns, or are they just considered to add unnecessary complexity and confuse users, as there is better ways to solve the same issue? If so, how would the the proper UE4 way of doing the same?
Cheers,
Markus