MoveToLocation not working

Hello. i spawn my pawn and AI controller, posses the pawn, and looking at the debug output everything works fine. I can call SetActorLocation and other pawn related functions but MoveToLocation seems not to work.

I tried this code in MyAIController’s Tick with 1 second timer:
GetPawn()->SetActorLocation(FVector(FMath::RandRange(-300, 300), FMath::RandRange(-300, 300), FMath::RandRange(-300, 300)));
And indeed i saw the random teleprotation every second.

But when i changed to this, nothing happens
MoveToLocation(FVector(FMath::RandRange(-300, 300), FMath::RandRange(-300, 300), FMath::RandRange(-300, 300)), -1.0f, true, false);

Do i need to create movement component for the pawn to make MoveToLocation work?

Do you have nevmesh?

Your pawns indeed need a movement component, preferable a CharacterMovementComponent, since it’s the one most navigation-feature-rich. And you don’t need to call the function every second - the way AI movement works in UE4 requires you to just call it once and AI will follow that request until destination is reached or movement is not possible (for example when AI is blocked).

And do make sure you have navmesh, like @Darkstorm1997 suggested :wink:

Cheers,

–mieszko

I do know that i dont need to call it every second :slight_smile: I just feel like using Tick to test stuff for the first time is just easy and efficient. Im goin to implement movement component and report back! And i want to move the pawn with navmesh, but when there is shorter path where u can fall, just go straight and fall to the lower ground

Dzieki za pomoc Panie Mieszku! :slight_smile:

Okay i added the movement component, the ComponentTick is ticking but nothing happens. MoveToLocation still doesnt move

Okay i changed pawn to character and it works. That UE is so ■■■■ strange