Announcement

Collapse
No announcement yet.

Blackboard Keys on C++

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Blackboard Keys on C++

    Hi! I'm transitioning from Blueprints to C++ and I'm trying to use blackboard keys on my service but I'm not sure how to do it and I can't find proper documentation for it.
    What would be the equivalent of a Blackboard key selector on C++ and get/set blackboard value as x?

    Thanks in advance

    #2
    Within your C++ you'd define a property such as:

    FBlackboardKeySelector MyBlackboardKey.

    Then you end up with:

    I.e: ExecuteTask(UBehaviorTreeComponent& OwnerComp,...)
    UBlackboardComponent* MyBlackboard = OwnerComp.GetBlackboardComponent();
    MyBlackboard->ClearValue(Key.SelectedKeyName);
    MyBlackboard->GetValueAsBool(Key.SelectedKeyName);
    ​​​​​​​MyBlackboard->SetValueAsBool(Key.SelectedKeyName, false);

    Comment


      #3
      Originally posted by wushu_pbrooks View Post
      Within your C++ you'd define a property such as:

      FBlackboardKeySelector MyBlackboardKey.

      Then you end up with:

      I.e: ExecuteTask(UBehaviorTreeComponent& OwnerComp,...)
      UBlackboardComponent* MyBlackboard = OwnerComp.GetBlackboardComponent();
      MyBlackboard->ClearValue(Key.SelectedKeyName);
      MyBlackboard->GetValueAsBool(Key.SelectedKeyName);
      MyBlackboard->SetValueAsBool(Key.SelectedKeyName, false);
      Thanks! Sorry for the late answer. I was expecting an automatic notification or something like that but then I noticed I wasn't subscribed to the thread

      Comment


        #4
        Originally posted by wushu_pbrooks View Post
        Within your C++ you'd define a property such as:

        FBlackboardKeySelector MyBlackboardKey.

        Then you end up with:

        I.e: ExecuteTask(UBehaviorTreeComponent& OwnerComp,...)
        UBlackboardComponent* MyBlackboard = OwnerComp.GetBlackboardComponent();
        MyBlackboard->ClearValue(Key.SelectedKeyName);
        MyBlackboard->GetValueAsBool(Key.SelectedKeyName);
        MyBlackboard->SetValueAsBool(Key.SelectedKeyName, false);
        To be 100% accurate, in this particular example it should be:

        Code:
        UBlackboardComponent* MyBlackboard = OwnerComp.GetBlackboardComponent();
        MyBlackboard->ClearValue(MyBlackboardKey.SelectedKeyName);
        MyBlackboard->GetValueAsBool(MyBlackboardKey.SelectedKeyName);
        MyBlackboard->SetValueAsBool(MyBlackboardKey.SelectedKeyName, false);
        The variable "Key" appeared out of nowhere and might be misleading.

        Also, you should declare the key as public and with below property to make it editable in the editor:

        Code:
        UPROPERTY(EditAnywhere)
        FBlackboardKeySelector MyBlackboardKey;
        Last edited by pdenton; 08-20-2020, 04:47 AM.

        Comment

        Working...
        X