Game Development Reference
In-Depth Information
else
{
curWaypoint++;
Destination =
Waypoints[curWaypoint].position;
}
}
}
}
What Patrol will now do is check the Distance variable. If it is far from the current
waypoint, we set that waypoint as the new destination of our AI. If the current way-
point is close to the AI, we check the ReversePath Boolean variable. When Re-
versePath is true , we tell the AI to go to the previous waypoint, going through the
path in the reverse order. When ReversePath is false , the AI will go on to the
next waypoint in the list of waypoints.
With all of this completed, you now have an AI with pathfinding abilities. The AI can
also patrol a path set by waypoints and reverse the path when the end has been
reached. We have also added abilities for the AI to search for the player as well as
flee from the player.
Search WWH ::




Custom Search