NavMeshAgent following road (even if slightly longer path)

Hey all!

I have a basic scene with a plane as a ground and another thinner plane sitting on top of the ground that is acting as the road.

How would I make the NavMeshAgent follow the road rather than walk on the regular ground? I know if the Agent follows the road it will have a longer path, however, this is desired.

Things I’ve tried and their results:

  • Set ground on NavMeshLayer with cost of 1 and road on seperate NavMeshLayer with cast of 0.5 (no difference in path)
  • Same as above but changed road layer’s cost to 5 (just a test to see what happens). Agent purposefully avoids road
  • Same as above but set Ground layer’s cost a large number (10) and road’s cost to a negative number (-10). No difference in path.

Could the problem be that the road object is sitting on top of the ground? In other words: 2 layers overlapping? If this is the problem how would we overcome this?

why789

You should go into Window > Navigation, then select the plane under the road, and select Not Walkable in the Navigation panel. Mess around with the settings to get the result you want.