Download

MoveToActor() Dont works

Waypoint found and Should move are wrote in output log, but AI is not moving. What is wrong?


void AExampleAIController::BeginPlay()
{
Super::BeginPlay();


AAI_ExampleCharacter* OwnerCharacter = Cast<AAI_ExampleCharacter>(GetPawn());
if (OwnerCharacter == nullptr)
{
UE_LOG(LogTemp, Error, TEXT("Owner is nullptr"));
return;
}
for (AWaypoint* WayPoint : TActorRange<AWaypoint>(GetWorld()))
{
bool IsInWaypoint = WayPoint->AllowedAccess.Contains(OwnerCharacter);

if (IsInWaypoint == true)
{
Routes.Add(WayPoint);
UE_LOG(LogTemp, Error, TEXT("Waypoint found"));
}
else
{
UE_LOG(LogTemp, Error, TEXT("Waypoint not found"));
}

}
RecieveMoveCompleted();
}
void AExampleAIController::CallMove()
{
}
void AExampleAIController::Tick(float DeltaSeconds)
{
Super::Tick(DeltaSeconds);
UE_LOG(LogTemp, Error, TEXT("Tick"));
if (Move == true)
{
MoveToActor(Routes[0], 100, true, true, true, NULL, false);
UE_LOG(LogTemp, Error, TEXT("Should move"));
}
}


void AExampleAIController::RecieveMoveCompleted()
{
for (int32 i = Routes.Num() - 1; i > 0; i--) {
int32 j = FMath::Floor(FMath::Rand() * (i + 1)) % Routes.Num();
AWaypoint* temp = Routes*;
Routes* = Routes[j];
Routes[j] = temp;
Move = true;
}

}

Thanks for help.

Nevermind. I just forgot to put NavMesh.