MoveToActor and MoveToLocation Not Working in C++

I have the following bit of code in my class extending AAIController:

	UE_LOG(LogTemp, Warning, TEXT("MOVING TOWARDS CHARACTER %s AT POSITION %s"), *TargetedCharacter->GetName(), *TargetedCharacter->GetActorLocation().ToString());
	MoveToLocation(TargetedCharacter->GetActorLocation());

The log successfully prints out

LogTemp:Warning: MOVING TOWARDS CHARACTER Ash_C_0 AT POSITION X=-954.872 Y=134.872 Z=190.150
LogTemp:Warning: MOVING TOWARDS CHARACTER Ash_C_0 AT POSITION X=-852.143 Y=32.144 Z=190.150
LogTemp:Warning: MOVING TOWARDS CHARACTER Ash_C_0 AT POSITION X=-745.443 Y=-74.557 Z=190.150

But my character does not move.
So I tried to run MoveToLocation from BeginPlay, and there is still no movement.

However, if I run seemingly the exact same bit of code from Blueprints with a Blueprint extending AI Controller, like so:

The character will move to the location.

It seems very much like calling these functions from C++ is broken.
If there’s a way to fix this so that I could avoid Blueprints that would be wonderful!
If not, is there another workaround?

Update: I can also see here that when I use the C++ call, the status for the character is set to moving and there is a goal with a path and a path end.

Thanks!

1 Like

bumpity bump

can you send your actor to {0,0,0} as well in c++? may be because of the Z being 190 (up in the air) it thinks its an unreachable place so wont go.

Character still doesn’t move when sent to {0, 0, 0}, sadly. But man I’d hoped that was it.

Ok, from the docs AAIController::MoveToLocation | Unreal Engine Documentation Can you overload the MoveToLocation, upto a point where you can give it a bUsePathfinding value? seems like that is enabled in blueprint, so i think thats the reason

Creating a new project and redoing everything did the trick.
I still don’t know what was wrong, but if I figure it out, I"ll post it.

thanks for the help dude! this ended up not doing the trick, but i appreciate it.

Did you solve it? I have a same problem

… I got same issue and then discover I didn’t add “Nav Mesh Bounds Volume” to my stage. … after I add it, things roles sweet … ; ] ,

I know I can be late to the party but encountered exactly the same thing. Problem of course was in my code where I was not calling Super::BeginPlay() in my AIController BeginPlay override. I hope it helps somebody.

1 Like

Thanks, it solved my issue.

Man, you saved my life. I was looking for a solution about ai character not chasing my character and it was due Super::BeginPlay() was missing on my AI COntroller. Thank you a lot!