Download

MoveToActor not working but SetFocus does?

I’ve been doing some basic AI and i’ve managed to get a basic AI that ‘should’ move towards a pawn. I go through the breakpoints in my code here:



void ABaseAIController::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

	APawn* MyBot = GetPawn();
	if (MyBot == NULL)
	{
		return;
	}
	else if (!target)
	{
		for (FConstPawnIterator It = GetWorld()->GetPawnIterator(); It; ++It)
		{
			ALivingEntity* TestPawn = Cast<ALivingEntity>(*It);
			if (TestPawn && MyBot != TestPawn)
			{
				target = TestPawn;
				SetFocus(target);
				MoveToActor(target);
			}
		}
	}
	else if (MyBot != target)
	{
		SetFocus(target);
		MoveToActor(target);
	}

}


and it runs MoveToActor in both case but the pawn never moves. The bot does rotate, i.e. SetFocus but doesn’t go towards me. Is there anything that could cause this?

make sure your navmesh is fully compiled. If it’s not standing on the nav mesh it will look but not move. View paths and see if that area is built.

Thanks almost forgot it even used navigation mesh :smiley: