Building A Stealth Game — Creating Waypoints For Your AI Guards

Photo by Catarina Sousa from Pexels
Here is a simple four waypoint example made with cubes. We won’t need the cube meshes though.
The Waypoints variable is an example of a serialized List

float distance = Vector3.Distance(transform.position, waypoints[currentTarget].position);

if (distance < closeEnoughValue) {

currentTarget++;

if (currentTarget ≥ waypoints.Count) currentTarget = 0;

navMeshAgent.SetDestination(waypoints[currentTarget].position);

}

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store