Unreal, how can I make the blackboard value in bttask visible in the behavior tree?

This is my code:

#pragma once

#include "BehaviorTree/BTTaskNode.h"
#include "GuideMoveToActorCPP.generated.h"

/**
 * 
 */
UCLASS()
class DREAMTOWNAI_API UGuideMoveToActorCPP : public UBTTaskNode
{
    GENERATED_BODY()

public :
    UPROPERTY(Export)
    UBlackboardKeyType* TurnToActorKey;
    UBlackboardKeyType* DestinationActorKey;

private:
    float TangentLength;
    float Velocity;
    float SplineDistance;
    float SplineLength;
    float MoveTotalTime;
    float SplineTimeStart;
    float CurveMinTime;
    float CurveMaxTime;
    float XValue;

    //float MoveTime(float SplineLength);
    //FVector SecondPointTangent(FVector DirectionVector);
    
};

However, the key TurnToActorKey and TurnToActorKey don’t appear in the behavior tree.

119369-微信截图_20161220175333.png

You need FBlackboardKeySelector. See how BT nodes in AIModule utilize it.

Cheers,

–mieszko

Yes, I finally made it in the same way. And this is my code:

public:
    FName GetSelectedTurnToActorKey() const;
    FName GetSelectedDestinationActorKey() const;

    UPROPERTY(EditAnywhere, Category = Blackboard)
        struct FBlackboardKeySelector TurnToActorKey;
    UPROPERTY(EditAnywhere, Category = Blackboard)
        struct FBlackboardKeySelector DestinationActorKey;
......
FORCEINLINE FName UMyBTTask_BlueprintBase::GetSelectedTurnToActorKey() const
{
    return TurnToActorKey.SelectedKeyName;
}

FORCEINLINE FName UMyBTTask_BlueprintBase::GetSelectedDestinationActorKey() const
{
    return DestinationActorKey.SelectedKeyName;
}

Finally I use BTTask_BlueprintBase as the parent class. And using the code above, I achieve my goal.

1 Like