x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

C++ Behavior Tree Service Not Updating Blackboard

Since there is no documentation on this. Can someone point out why this code is not updating my blackboard? It makes no sense.

 void UBTService_AdmiralUpdateQueue::TickNode(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, float DeltaSeconds)
 {
     Super::TickNode( OwnerComp, NodeMemory, DeltaSeconds);
     UE_LOG(LogClass, Log, TEXT("Service Ticking."));
     if (OwnerComp.GetAIOwner())
     {
         UE_LOG(LogClass, Log, TEXT("Has a Controller."));
         //Get the AI Controller
         AAdmiralAiController* Controller = Cast<AAdmiralAiController>(OwnerComp.GetAIOwner());
         if (Controller)
         {
             UE_LOG(LogClass, Log, TEXT("Successful Cast."));
             //If Queue is bigger that 0.
             //Set blackboard keys to true.
             //PlayerQueue
             if (Controller->GetPlayerQueueSize() > 0)
             {
                 /* The selected key should be "bPlayerQueue" in the BehaviorTree setup */
                 OwnerComp.GetBlackboardComponent()->SetValue<UBlackboardKeyType_Bool>(SubmarineBlackboardKey.GetSelectedKeyID(), true);
             }
             else
             {
                 /* The selected key should be "bPlayerQueue" in the BehaviorTree setup */
                 OwnerComp.GetBlackboardComponent()->SetValue<UBlackboardKeyType_Bool>(SubmarineBlackboardKey.GetSelectedKeyID(), true);
             }
 }}}

Product Version: UE 4.10
Tags:
more ▼

asked Feb 24 '16 at 08:14 PM in C++ Programming

avatar image

LuLima
42 15 15 26

(comments are locked)
10|2000 characters needed characters left

2 answers: sort voted first

Hey rantrod, i just but both to be true to see if any would alter the default false option inside the blackboard.

The answer actually was i hade to Cache the blackboard key.

I have to override this function and cache all blackboard values that i'm using.

void UBTService_AdmiralUpdateQueue::InitializeFromAsset(UBehaviorTree& Asset) { Super::InitializeFromAsset(Asset); SubmarineBlackboardKey.CacheSelectedKey(GetBlackboardAsset()); PowerupBlackboardKey.CacheSelectedKey(GetBlackboardAsset()); MedalBlackboardKey.CacheSelectedKey(GetBlackboardAsset()); }

more ▼

answered Feb 26 '16 at 03:05 PM

avatar image

LuLima
42 15 15 26

avatar image rantrod Feb 26 '16 at 09:17 PM

Thanks for posting this. That would have definitely been a gotcha for me.

(comments are locked)
10|2000 characters needed characters left

You have both sides of your 'if' statement setting the bool value to 'true'. Try setting line 24 to 'false'.

Also, I'm not sure how GetSelectedKeyID is supposed to work at runtime. Instead of using "GetSelectedKeyID", try using:

 uint8 BlackboardKeyID = Blackboard->GetKeyID(DesiredKeyFName);
 OwnerComp.GetBlackboardComponent()->SetValueAsBool(BlackboardKeyID,  true);

The DesiredKeyFName will be something like:

 FName DesiredKeyFName(TEXT("PlayerQueueNonZero")); // or whatever you called it in the blackboard exactly
more ▼

answered Feb 25 '16 at 10:33 PM

avatar image

rantrod
1.5k 47 47 213

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question