Pathfinding Cost does not work

Unity version 2022.3.26f1, using AiNavigation 1.15.

Set the Pathfinding Cost using the following instructions.

The project looks like this.

Sphere travels to the opposite of the heavier COST Heav area.
Therefore, Sphere should be lighter in cost to bypass Walkble, which is lighter in cost,

In fact, it moves over the Heav area, taking the shortest distance.

Why is this?

The source code is below.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;

public class TestSphere : MonoBehaviour{

    NavMeshAgent nav;

    void Start()
    {
        nav = this.GetComponent<NavMeshAgent>();
       
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(1)) {
            var pos = transform.position;
            pos.z = -10;
            nav.SetDestination(pos);
        }
    }
}

BUMP

where is your area override setting it to the Heavy, mine seems to work

Thank you, I will try to get a copy of the article.
Heaby is set up this way.

well you have 2 surfaces that overlap… and so it can use the surface from the large rectangle…
you need to make a modification to the sufrace for your small rectangle to make it heavy… and then it will cut into the bigger if its set correctly like mine above

thankyou.

Wouldn’t this explanation cause the higher indexed Heavy to apply?

If several objects of different area types are overlapping, the resulting navmesh area type will generally be the one with the highest index. There is one exception however: Not Walkable always takes precedence. Which can be helpful if you need to block out an area.

Also, could you please push how you created the area

mine is 2 planes one on top of the other, the top most wins :stuck_out_tongue: you can see this by moving them.

Is it the Y coordinate of Transform?
Changing that did not change the movement.

Well yes it is the Y but, i made it till the pink was above the blue - which was like next to nowt higher, and so the active plane touched would be the slow one and tada, it now avoids the slower one

here

here i just added a modifier volume and set it up

Thank you very much.
I have set Y 0.5 for plane as follows, created a HeavyBox and set Y to 1, but the behavior did not change.

9807591--1408386--upload_2024-5-2_0-23-19.png

Is it this function?
https://docs.unity3d.com/ja/2021.1/Manual/class-NavMeshModifier.html
This appears to be an experimental feature. I have not tried it, but it may be that COST will not work without it!

well firstly you are looking at 2021.1 documentation :stuck_out_tongue: so, i dunno, i dont even think it was called ai navgation then, and has changed…

I dont have 2022.3 installed, but i can assure you when i had a plane so the higher cost area was on top, and set destination the other corner, it walked round it.

the modifier, same deal, i didnt even make a second object i just slapped the modifier on the same plane and set it to be where and what i wanted… so however you need it, its working whatever i do… only time it didnt work was when the blue navmesh was on top… although, turning off the collider may have something to do with it, i just made a plane and slapped a navmesh surface on it.

Can you please tell me what modifier you are referring to?

9807699--1408410--upload_2024-5-1_17-28-4.png

or
9807702--1408413--upload_2024-5-1_17-28-36.png

1 Like

Sorry. I sent a reply.
This method worked for me.
The method I did to deal with it, specifying Area in each of the two NavMesh, doesn’t work.