- Home /
A* Pathfinding, destroying a path once it has reached its end
I'm using arongranberg's A* Pathfinding Project for a 2D game, and i need to destroy a path once it has reached its end to call another class to do a patrol function, and then once the player is spotted call back the class i left to make the AI follow the Player.
It goes like this:
AI follows PLAYER until its out of sight, then i need to DESTROY the path created, AI goes to Patrol mode, AI spots Player, AI follow player until it goes out of sight.
Here's where i need to destroy the path:
FixedUpdate(){
//(stuff here...)
if (currentWaypoint >= path.vectorPath.Count) {
if (pathIsEnded)
return;
Debug.Log ("End Of Path Reached");
if (useVelocity)
rb.velocity = Vector2.zero;
if (chasing == false) {
Debug.Log("chasing false");
ep.spotted = false;
chasing = false;
seeker.enabled = false;
ep.Start();
}
pathIsEnded = true;
return;
}
}
Thank you guys.
Your answer
Follow this Question
Related Questions
FixedUpdate is Being Called Less and Less Over Time...Why? 1 Answer
Find the closest point of an Invalid or Partial path 0 Answers
Delete Astar Path gride graph around a particular Object 1 Answer
how do I add abilities(Scripts/GameObjects) to my path finding agent 1 Answer
A* pathfinding for 2D top Down 0 Answers