Why AIMoveTo not work in c++?

Here is my code sample:

        		AAIController* AIController = Cast<AAIController>(GetController());
        		if (AIController)
        		{
        			AITask = UAITask_MoveTo::AIMoveTo(
        				AIController,
        				FVector(370, -370, 0),
        				NULL
        			);
        			if (AITask)
        			{
        				UE_LOG(LogTemp, Warning, TEXT("ybx--Begin AIMoveTo, AITask success"));
        			}
        		}

the return value AITask is not null, but the ai not move at all !!

and if i call this function in bluepirnt, the ai move correctly!
so, i’m really don’t know…

any suggestion would be great appreciated!

Hey RainStone,

Try to use the function MoveToLocation() in your controller.

Hope this helps,
Elias

I have a same problem, I try to use MoveToLocation. It is not work. You guys solve the problem?

Ran across this randomly and saw it wasn’t answered. I’m gonna put an answer down in case anyone else runs into this issue:

MoveToLocation has several parameters that can be set to tweak the movement. The simplest answer is to make sure you use the first three of them. Try MoveToLocation( vectorToGoTo, -1, false)

Always check out the docs (in this instance, AAIController::MoveToLocation | Unreal Engine Documentation ) to get a rundown of what every parameter does

2 Likes