A* Pathfinding Project

Set AI Destination Setter target to 6 Waypoints and loop


#1

Hi, I am currently setting the AI Destination Setter target in the OnTriggerEnter2D to go to 1 GameObject. Now i need the target to go and loop through 6 Waypoints which are stored in a Transform[]. Any help would be appreciated. Thanks


#2

Hi

You could take a look at the Patrol script. Simply replace the AIDestinationSetter with the Patrol script and it should do pretty much what you want.


#3

But at first i only have 1 target which is the pacman, then once an energizer is triggered i want it to go to the 6 waypoints. I am still able to use the Patrol Script? cause of course i cant use them both


#4

Hi

Sorry for the late answer.
In that case I suppose you could first set the patrol’s target list to a single object, and then change it to a list of 6 targets. Or you could copy the Patrol script’s code and add your logic there. The Patrol script is just modifying the ai.destination property under the hood and the script is quite short.