I’m newcomer in Unreal4.
I’m following tutorial and I learning making AI. I make script using c++, because I want to get good readability about my code.
Anyway, the tutorial said making AI using setTime and MoveToAI in blueprint. But I can’t find the api in c++. So I make the below code.
void ABaseAIController::BeginTimer()
{
_World = GetWorld();
if (_World)
{
DebugManager::LogError("Set timer");
GetWorldTimerManager().SetTimer(_TimerHandler, this, &ABaseAIController::OnAIMoveTo, 1.0f, true);
}
}
void ABaseAIController::OnAIMoveTo()
{
_Target = UGameplayStatics::GetPlayerCharacter((UObject*)_World, 0);
if (_Target)
{
DebugManager::LogError(_Target->GetTransform().GetLocation().ToString());
MoveToLocation(_Target->GetTransform().GetLocation(), 10.0f);
}
}
Log working well. But Ai character is not moving. I made navmesh volum and character. But when I using blueprint It work. What am I miss? and Can I use ‘AIMoveTo’ function in c++?