Thanks for aron’s pathfinding system.
I use grid graph for pathfinding.
my problem:
- AI didn’t move round the obstacle(named obstacleB), the detail picture is: .
1.1 If I create obstacleA by: GameObject->Create other->Cube, AI can move around obstacleA, it is ok.
1.2 But if I create obstacleB though my code when loading the scene, It seems like there isn’t any grid grah around
obstacleB, and the path marked by green line entered into the obstacleB.
Can you tell me how to solve it? Tanks!
I don’t Updates Graph during Runtime, this may be the reason?
Hi
If you are creating the GameObject after the graphs have been scanned (which is also in Start). You need to either rescan the graphs (AstarPath.active.Scan ()) or use graph updates.
Also try changing the Seeker component -> Start End Modifier -> End Point to ClosestOnNode.
Also, your image is not working. You have tried to link to a local file on your computer.
Thanks for your reply, I have solved the problem by using graph updates.
And I have another problem, If you have time, please help me.
How can I get the distance between AI and the target? If the distance is more than 1000, I don’t want to AI to move to the target. If the distance is less than 1000, AI can move to the target. Please give me some adivices.
Thanks in advance!
A simple Vector3.Distance (or .sqrMagnitude is even better) would work as an initial check. Then you can use GetTotalLength function.