Generating OffMesh Links for AI in Unity

Chris Hilton
3 min readJan 27, 2023

--

Objective: To allow our AI Agent to bridge gaps in floors using OffMesh Links in Unity.

Here we can see above that we have a platform next to the last waypoint, but the AI Agent is unable to reach it because there is no NavMesh surface to walk on. How do we solve this issue? Offmesh Links!

Building the Offmesh Link

First we need to make sure that we rebake the new platform into the scene:

Next, I am going to add the ‘OffMesh Linkcomponent to the new platform:

Here, we need to provide a starting point and an end point, which in my case will be — waypoints F and G.

Note: Beware of where you place the game objects on the Y-axis as the AI Agents trajectory is calculated from it’s base and usually targets the centre point of a primitive game object (it’s pivot point), resulting in an upwards vector followed by a short snap to position as shown below:

Notice the red lines projection from the base of the AI Agent to the middle of the cube.

How to Solve

Make sure the game objects pivot point is on the same level of Y-axis as the AI Agent:

--

--