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"

AIController RunBehaviorTree not work

HI I wanted change Behavior Tree in Runtime.

RunBehaviorTree Function return true but not work Behavior Tree.

this is my code.

 void AMonsterBaseController::Possess( APawn* InPawn ) {
     Super::Possess( InPawn );
 
     Owner = Cast<AMonsterBase>( InPawn );
 
     if ( !Owner ) {
         UE_LOG( LogClass, Log, TEXT( "MonsterBaseController Get Onwer Null" ) );
     }
 
     if ( Owner->GetStateByBehaviorTree( AMonsterBase::EBaseState::Chase )->BlackboardAsset ) {
 
         Blackboard->InitializeBlackboard( *Owner->GetStateByBehaviorTree( AMonsterBase::EBaseState::Chase )->BlackboardAsset );
 
 bool rtVal = RunBehaviorTree( Owner->GetStateByBehaviorTree( AMonsterBase::EBaseState::Chase ) );
 
          if ( !rtVal )
              GEngine->AddOnScreenDebugMessage( -1, 10, FColor::Blue, TEXT( "Behavior Tree Not Run" ) );
     }
 }
 

What should I do

Product Version: UE 4.10
Tags:
more ▼

asked Mar 29 '16 at 10:07 AM in C++ Programming

avatar image

baehun92
6 2 7

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Try calling StopTree on your UBehaviorTreeComponent before calling RunBehaviorTree and see if that helps.

 UBehaviorTreeComponent* BTComp = Cast<UBehaviorTreeComponent>(BrainComponent);
 if(BTComp) BTComp->StopTree();
 bool rtVal = RunBehaviorTree( Owner->GetStateByBehaviorTree( AMonsterBase::EBaseState::Chase ) );

...

more ▼

answered Mar 30 '16 at 05:56 AM

avatar image

rantrod
1.5k 48 47 216

avatar image baehun92 Mar 30 '16 at 02:57 PM

Oh It is Work Than you.

but It work Only In Tick Function Not Work in Possess Function Can I know why not work in Possess Function?

avatar image rantrod Mar 30 '16 at 05:14 PM

You don't need the call to InitializeBlackboard, it gets automatically called from RunBehaviorTree, but you do need the StopTree before it.. I don't see other errors in the code you provided. Perhaps the error is elsewhere?

avatar image baehun92 Mar 31 '16 at 02:07 AM

Do not see any errors.

Debug That Code But Work Well

I am not Use Possess Function and Project well making thank you

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
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