Path always ends in same spot

Hi there,

I am trying to do basic pathfinding with my agents (the blue capsules) and destinations (the red sphere). I have a script running which mimics standard RTS unit/destination mouseclicks- when I have a capsule selected, I feed the location of the destination (in this case, the red sphere) into AIPath pathfinding. In this case, that location is in the middle of the sphere.

The problem is, is that when I do this, the pathfinding ALWAYS tries to go to the same spot in front of the sphere, no matter where the agents start from. I have highlighted in a dotted red line where I would expect the path to go…I’m sure I have some setting wrong or something. I can send more screenshots if needed.

Hi

The agent will always try to move to the closest point it can reach. In this case, it looks like the spot in front of the sphere is the closest (maybe just by a tiiiny amount). If you want multiple locations to be valid targets, you could either bias the destination slightly towards the agent’s position (just move it half a meter or something towards the agent), or use a MultiTargetPath (MultiTargetPath - A* Pathfinding Project).

Hi Aron, thank you for the swift reply!

I see what you mean…the closest point IN REACH is the point in front of the circle.

For MultiTargetPath, how could I ensure that it would produce paths closer to the agent? I.e. not give me paths on the far side of the circle, or the top and bottom of it.

The MultiTargetPath will find the shortest path to any of the alternative target points (or all of them if path.pathsForAll is enabled, but you don’t want that in this case).