UE4 Pathfinding...basic AI

Why the bot is not moving?

d85ee49070f9dd6c2470f8b3767b53ef7fd886ef.jpeg


// 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;
}