Hi Im new in Unreal Engine.
I have problem. I was searching through internet to resolve it but nothing i found was helpful ;/
I want use AI to move my actor to other’s actor location / follow him.
In photo you can see my black board and behavior tree(its calling Move To then returning and skipping **Wait **node).
My controler class:
#include "AIControllerWolf.h"
#include "BehaviorTree/BlackboardComponent.h"
#include "BehaviorTree/BehaviorTreeComponent.h"
#include "BehaviorTree/BehaviorTree.h"
#include "Runtime/Engine/Classes/Kismet/GameplayStatics.h"
#include "Wolf.h"
#include "Pig.h"
#include "AnimalTargetPoint.h"
AAIControllerWolf::AAIControllerWolf()
{
//Initialize the behavior tree and blackboard components
BehaviorComp = CreateDefaultSubobject<UBehaviorTreeComponent>(TEXT("BehaviorComp"));
BlackboardComp = CreateDefaultSubobject<UBlackboardComponent>(TEXT("BlackboardComp"));
}
void AAIControllerWolf::OnPossess(APawn* Pawn)
{
//Super::Possess(Pawn);
//Get the possessed Pawn. If it's the AI Character we created
//initialize it's blackboard and start it's corresponding behavior tree
AWolf* Wolf = Cast<AWolf>(Pawn);
if (Wolf)
{
if (Wolf->BehaviorTree->BlackboardAsset)
{
BlackboardComp->InitializeBlackboard(*(Wolf->BehaviorTree->BlackboardAsset));
BehaviorComp->StartTree(*Wolf->BehaviorTree);
TArray<AActor*> FoundActors;
UGameplayStatics::GetAllActorsOfClass(GetWorld(), APawn::StaticClass() , FoundActors);
BlackboardComp->SetValueAsObject(BlackboardKey, FoundActors[0]);
}
}
}
void AAIControllerWolf::SetSeenTarget(APawn* Pawn)
{
//Registers the Pawn that the AI has seen in the blackboard
if (BlackboardComp)
{
BlackboardComp->SetValueAsObject(BlackboardKey, Pawn);
}
}
What am i missing ?
Dawid
PS: Sorry for my english