How c++ Enum use in Behavior tree

I am interesting in how to use my c++ enum in Behavior tree from blackboard.
I create Blueprint function library and I can add to any actor and use it. But how Blackboard tree can access to my c++ enum code?

My example below:

UCLASS()
class MYGAME_API UConstants : public UBlueprintFunctionLibrary
{
	GENERATED_BODY()
};
UENUM(BlueprintType)
enum class EUnitMainState : uint8
{
	Idle = 0 UMETA(DisplayName = "IDLE"),
	FollowPlayer UMETA(DisplayName = "FOLLOW PLAYER"),
	Action UMETA(DisplayName = "ACTION")
};
1 Like

It’s not very clear in the UI, but the way to do this is:

  1. Setup your enum (as you have done)
  2. Within your blackboard, add a new ‘Enum’ variable type
  3. Expand the Key Type
  4. You won’t be able to fill in the ‘Enum Type’ from the selector. but you can enter a custome name in the ‘Enum Name’ field. Enter you’re enum name here (e.g. EUnitMainState)
  5. Once you typed the name, be sure to hit enter
  6. Check the ‘Is Enum Name Valid’ tickbox. It should now be ticked. If not then it’s because you’ve entered the name incorrectly or you may need to re-compile the project. You should also now see the Enum Type field is filled in too.

Here’s a screenshot of the final result

8 Likes

Thank you very much! It’s work!

Glad it helped! Can you mark this answer as accepted to help others find it when they have the same issue. Thanks.

please accept this answer.