Hi All
I have an Enum in a C++ AI controller that I’m using in a blackboard. I have the header
#include "BehaviorTree/Blackboard/BlackboardKeyType_Enum.h"
In the AI Controller. As well as the enum;
UENUM(BlueprintType)
enum class EBehaviorType : uint8
{
Indifferent UMETA(DisplayName = "Indifferent"),
Receptive UMETA(DisplayName = "Receptive"),
Chat UMETA(DisplayName = "Chat"),
GoSomewhere UMETA(DisplayName = "GoSomewhere"),
Hostile UMETA(DisplayName = "Hostile"),
Fight UMETA(DisplayName = "Fight")
};
In the blackboard the key type is Enum and writing EBahaviorType in the Enum name causes it to appear in EnumType and the Is Enum Name Valid box to be automatically ticked.
However, if I write, for example;
BlackboardComp->SetValue<UBlackboardKeyType_Enum>(ModeID, NewBehaviorType);
In a function which is passing in a new EBehaviorType, it won’t compile. I get the following error;
Error 1 error C2664: 'bool UBlackboardComponent::SetValue<UBlackboardKeyType_Enum>(FBlackboard::FKey,UBlackboardKeyType_Enum::FDataType)' : cannot convert argument 1 from 'int32' to 'const FName &'
Is this a bug?
Thanks!
EDIT: I added the line
const FName& ModeName = BlackboardComp->GetKeyName(ModeID);
And used that instead of the keyID as the first argument passed to SetValue. Now the error is;
Error 1 error C2664: 'bool UBlackboardComponent::SetValue<UBlackboardKeyType_Enum>(FBlackboard::FKey,UBlackboardKeyType_Enum::FDataType)' : cannot convert argument 2 from 'EBehaviorType' to 'UBlackboardKeyType_Enum::FDataType'