Hey everyone, I’m pretty much at my wits’ end with this.
I’m having issues with using MoveTo, either from the behaviour tree or with the Move to Location node etc.
Basically, my characters will usually circle around actors when moving to them instead of moving directly towards them. Even when they’re already within the acceptance radius range, they’ll often just navigate way farther than they need to.
I’ve tried messing around with the navmesh’s cell size, agent radius etc. and while it helps a tiny bit, it’s a long way off from what I’d want (on top of being performance hungry).
Not using pathfinding fixes the issue, i.e. my characters will go straight to the target actors without circling around them. They will obviously get stuck in any obstacle between them and their target, however.
Does anyone have anything to suggest that could help me find a solution? The more I progress, the more I feel like grid-based movement would be easier to manage, but I have no knowledge on how to begin to implement that.
Am I doing something wrong or does this look like a limitation of UE’s pathfinding?
Are you sure you don’t have an environment query running somewhere?. It looks like the AI is getting the the character and then trying to hide from it.
I’ve drawn a little red and blue line just to show what it’s doing and what I’d expect.
What’s weird is that I’d expect the acceptance radius or navmesh cell size and agent radius to have more of an effect but my character is always taking really weird paths.
It’s only with pathfinding and when the target affects the navmesh to. Moving to a specific point works well… Technically, moving to a point near the target first (with pathfinding), then moving to the target in a straight line would work, but that sounds a bit hacky.
This reddit post got me on the right track to implement a solution that fills my needs…
I do a box trace around the actor to determine available spots then my character iterates through those spots to figure out which spot is closest and pick that spot. This also makes it a lot less chaotic when multiple characters try to move to an actor at once since they’ll just pick an open spot and move there instead of trying to pile up at the same spot.
I had messed around with detour crowd AI and it was way too messy for me.
My conclusion is that pathfinding is fine to get from point A to point B but once your character has reached its destination, it’s better to have separate solutions to determine exactly where they should go.
I had a look at the “Cropout” example project and saw it had the exact same problem where units will randomly go around rocks and trees instead of taking the shortest path… I’m a little surprised I found so little information on the subject.