Why the bot is not moving?
// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
#include "Nex.h"
#include "BTTask_MyMove.h"
UBTTask_MyMove::UBTTask_MyMove(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
{
}
EBTNodeResult::Type UBTTask_MyMove::ExecuteTask(UBehaviorTreeComponent* OwnerComp, uint8* NodeMemory) const
{
UBehaviorTreeComponent* MyComp = OwnerComp;
ANexAIController* MyController = MyComp ? Cast<ANexAIController>(MyComp->GetOwner()) : NULL;
if (MyController == NULL)
{
return EBTNodeResult::Failed;
}
else
{
// GetSomeLocation is just made up here, it's just an example
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, TEXT("Key"));
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, FString::FromInt(BlackboardKey.SelectedKeyID));
FVector Destination = MyComp->GetBlackboardComponent()->GetValueAsVector(BlackboardKey.SelectedKeyID);
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, FString::FromInt(Destination.X));
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, FString::FromInt(Destination.Y));
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, FString::FromInt(Destination.Z));
// Make a move
MyController->MoveToLocation(Destination, 60.0f);
return EBTNodeResult::Succeeded;
}
return EBTNodeResult::Failed;
}