If I want to extend AIPath, should I write directly inside it? But I also want to call a GameObject in the game. Should I copy the code into my own project? And how should I modify the AIPath editor? I want to drag and assign some of my own new variables

If I want to extend AIPath, should I write directly inside it? But I also want to call a GameObject in the game.

Should I copy the code into my own project? And how should I modify the AIPath editor? I want to drag and assign some of my own new variables.

If I want to stop at a certain point, like the one on my map, how should I call the function?

My point is calculated using OnPathComplete to determine the distance. Where should I stop after reaching that point?"

image

Hi

You can subclass the AIPath component if you want. You can also subclass its editor script.
However, I recommend trying to interact with the AIPath component via separate scripts as much as possible, instead of subclassing.

If you want the agent to stop at a specific point, then set that point as the agent’s destination.

“If I provide a destination point, is there a method or property that can tell me if the pathfinding is feasible?” :upside_down_face:

You can use PathUtilities - A* Pathfinding Project for that

“Thank you very much! The last question is, how can I find the closest path to an object from the player? Since the object has a collider, I can’t navigate directly to the center, and the closest point in a straight line between the player and the object may not be the nearest due to obstacles. My idea is to generate a point every 10° around the object’s radius and then determine which of these 36 points is the closest. Is there a better approach?”

0da65fb5882b7a544ae85ee4df531e7

Hi

Typically, a heuristic of “just move the destination ever so slightly closer to the agent” works just fine.
But otherwise you can do what you describe with a MultiTargetPath.

Hello, I tried using the method you mentioned to determine if a point is reachable, but sometimes it still ends up on the edge, preventing the movement from being completed. I would like to ask if there’s a way to detect when the character is stuck and unable to move? I want to use this method to find another point to move to when this happens.