Unity Navagation Ground Mapping

ok, I normally answer questions, but today I’m the one asking them. I know how unity has different layers you can apply to the Navigation map, which NavAgents use to plan out their paths… always going the easiest way possible. And that you can assign weights to these layers… HOWEVER If you tell a troop to move to an area that isn’t recommended, the agent will still move there if possible… however, this troop will move through a ‘mud region, 20’ as fast as ‘pathway, 0.2’. Is there a way to slow down the agent depending on the weight of the current layer it is in?

just bring down the agent’s speed if you sense you’re in the mud. Something like:

NavMeshHit hit;
Navmesh.SamplePosition (transform.position, out hit, Mathf.Infinity, Physics.AllLayers);
if (hit.areaMask == mudMask) {
    agent.speed = slowSpeed;
} else {
    agent.speed = normalSpeed;