Moving Agents on Navmesh

Objective: Set up waypoints and have the navmesh agent move through a list of waypoints

Ed Hepplewhite
2 min readAug 24, 2023

To get started add a floor with a navmesh, a navmesh agent, and some waypoints.

The goal here is to have the agent move to our starting waypoint, then sequentially move through all of the others. When the agent reaches the laswt waypoint, the waypoint order is reversed and he moves through them backwards. Once he’s back to the start, he reverses again and moves through the waypoints.

First, we need to make a list of waypoints.

On start, we create the list of waypoints.

Then, if the agent is close enough to the target, the list is incremented and he moves to the next waypoint in the list.

If he hits the end, we the the reverse and decrement the list. If he gets back to the beginning, we run through the list incrementing again.

--

--