Adding Speed Cost to Terrain Types

I have different terrain types (forest, mountain, plains) and these are handled with Tags/Penalties no problem. The PlayerCharacter avoids mountains to walk in the plains.
What I’d like to do now is add an additional speed penalty to each terrain. For example, if the PlayerCharacter must go over the mountain terrain (ie. using the nodes tagged with a mountain penalty) I want the character to slow down considerably(the AI Path -Max Speed to lower). The plains wouldn’t slow them down at all, the forest would a little bit.
I’m unsure how to go about doing this. I believe it must be done as part of the initial pathfinding formula calculation because otherwise I could end up with a situation where the best possible route calculated is actually much slower than another route due to the speed cost applied afterwards.
Hope that’s clear.
Any advice?


You are correct in that you would be using tags/penalties for this. A higher penalty is essentially the same as the pathfinding system thinking it takes longer to traverse those nodes.
Then you can modify the speed of the agent on the fly using something like

void Update () {
    var node =, NNConstraint.Default);
    var speed = do something with node.Penalty or node.Tag here;
    ai.maxSpeed = speed;