The following codes compiled fine but when I play Unreal crashes.
// Fill out your copyright notice in the Description page of Project Settings.
#include "Hunter.h"
#include "AIController.h"
#include "Math/UnrealMathUtility.h"
#include "NavigationSystem.h"
void AHunter::BeginPlay()
{
Super::BeginPlay();
Wandering();
}
void AHunter::Wandering()
{
if (!GetController()->IsPlayerController())
{
FVector GetLocation = SetLocation();
GetController<AAIController>()->MoveToLocation(GetLocation);
}
}
FVector AHunter::SetLocation()
{
FNavLocation OutLocation;
UNavigationSystemV1 FindPath;
if (FindPath.GetRandomPointInNavigableRadius(this->GetActorLocation(), NavRadius, OutLocation))
{
return OutLocation.Location;
}
else
{
return this->GetActorLocation();
}
}
NavigationSystemV1 FindPath is at line 28
GetController()->MoveToLocation(GetLocation) is at line 21
What am I doing wrong?