Character using AIController's MoveToActor not taking a straight line path

I’m trying to get a Character to move to a goal actor on a navmesh, using the MoveToActor function in AIController to move the character. At the start and end of the character’s movement, the character moves to the side, when I expected the character to take a straight path. Depending on the position of the two actors, it sometimes even goes behind the goal actor.
navmesh_issues

I’ve also tried using just a Pawn with UFloatingPawnMovement, rather than a full Character, and got the same results. I think I must have something set up wrong with my navmesh, but I’m not sure what the problem could be. I’ve tried changing some of the settings (like the tile size) in Project Settings → Navigation Mesh, but haven’t had any success there. Any ideas on what I’ve done wrong?

I’m using C++ and UE 5.2.1

Going behind can be explained by the AI not being able to reach it’s destination, therefore does a little circle around it. Yes, it should also be able to reach going straight if it can by going around it but because it foresees that it cannot, it starts traversing around while getting closer and at some point it passes the nav mesh bound due to it keeping it’s existing velocity, making it reach the acceptable radius. This can be fixed by either decreasing the cell size from the details window that opens when your recast nav mesh is selected, or increasing the acceptable radius of your Move To Actor function.

About the off movement at the start, the only thing I can think of is the pathfinding algorithm detecting a shorter path and doing a little detour. It seems illogical upon observing your GIF, but maybe there’s something we’re missing. Maybe try placing the AI on different parts of the map.

To provide some guidance on your debugging process, you can project it’s navigation via the function to get some clues on what’s happening (also open the AI debugger during runtime), you can try using the Move To Location function instead and plug the target actor’s location into the destination pin, and you can try doing this exact experiment in a completely flat surface.

Hope these can be helpful :innocent:

the weird movement at the start its because its trying to avoid itself, something in the actor has ‘CanEverAffectNavigation’ or DynamicObstacle etc

Thanks for the tips! I’ve tried increasing the acceptance radius and using MoveToLocation, and it’s still moving off to the side of the target. I’ll do some more debugging using your other suggestions and see if I can make some progress

Good call, this was the issue with the movement at the start. The sphere that I put on the character had CanEverAffectNavigation set to true. I didn’t think it would be an issue since I wanted characters moving around to avoid each other, but after digging into it more, I should be using avoidance algorithms for that rather than having characters affect the nav mesh. Thanks!

Still having issues with this, hoping for some more help. I switched from using MoveToActor to using MoveToLocation (all default parameters) with a point that should be on the navmesh. It’s still taking the wrong path around obstacles for some positions.
path_going_around
With the destination to the left of the obstacle, I would expect the pawn to move to the left side as well, but it goes around the long way to the right.

Here’s a top-down view of the visual logger’s output, showing the path that was calculated

Any more ideas about what could be going wrong?