[RELEASED v1.4.4] Nav3D - easy pathfinding in 3D space

Update…If I have a clone of object, that is visible at begging, then code above works (for another object).

gameobject1 has the same mesh as gameobject2
gameobject2 has NotifySpaceManager attached
gameobject2 is not enabled at scene start

OK SCENARIO:
//////////////////////////////////////////////////////////
gameobject1 —enabled < detected
gameobject2 —disabled < not detected

then enable gameobject2, which has NotifySpaceManager behaviour

gameobject1 —enabled < detected
gameobject2 —enabled < detected by spacemanager

ERROR SCENARIO:
//////////////////////////////////////////////////////////
gameobject2 —disabled < not detected

then enable gameobject2, which has NotifySpaceManager behaviour

gameobject2 —enabled < not detected by spacemanager (ERROR!!!)

It seems, that UpdateGraphForObstacle doesn’t work, if there is not a GameObject with the same mesh available at the start of scene.

I guess method should have functionality to automatically add mesh, if it is not present.

Hi again.

I checked the performance of the obstacle handling functions. SpaceHandler really had a bug. We have already fixed it and it will be fixed in a new update coming soon. So that you can resolve this error in your home space, replace the line at number 255 “if (staticObstacleTags.Contains(obstacleGOToUpdate.tag) && meshFilterInst && meshFilterInst.sharedMesh)” in the SpaceHandler class with this “if (meshFilterInst && meshFilterInst.sharedMesh)”.

I also created a test scene to test the processing of new obstacles and remove existing ones. I attached a link for downloading. In the project, you need to import the asset file into project and add the SpaceManager script to the scene.

Thank you for noticing the problem and letting us know!

Thanks.
It worked, I can now see boxes around meshes.

I have however another problem:

SpaceHandler never calls NotifyRediness.

And then, I cannon find path. Even if I force calling it, path doesnt return.
I guess something gets stuck in working queue?

The setting “Graph obtaining at scene start” in the inspector SpaceManager set to true? If not, then when you start the scene, you must manually make a call to SpaceManager.HandleAllObstaclesOnScene ().

And we also found an error that could prevent the correct call of NotifyRediness
To fix it, please replace the function HandleAllObstaclesOnScene () with the following code:

public bool HandleAllObstaclesOnScene()
        {
            //selection all GameObjects at scene
            List<GameObject> generalGOList = GameObject.FindObjectsOfType(typeof(GameObject))
                .Select(item => (GameObject)item).ToList();

            //selection of objects, having mesh collider,terrain, or prohibited tag
            generalGOList = generalGOList.Where(go =>
                !go.GetComponent<Pursuer>() && go.activeInHierarchy && (
                    go.GetComponent<MeshCollider>() && go.GetComponent<MeshCollider>().sharedMesh &&
                    go.GetComponent<MeshCollider>().enabled == true ||
                    staticObstacleTags.Contains(go.tag) && go.GetComponent<MeshFilter>() &&
                    go.GetComponent<MeshFilter>().sharedMesh ||
                    go.GetComponent<Terrain>() && go.GetComponent<Terrain>().enabled == true
                )).ToList();

            if (generalGOList.Count == 0)
            {
                NotifyRediness();
                return false;
            }

            totalTrisCount = CountTheTotalNumOfTris(generalGOList);
            foreach (GameObject go in generalGOList)
                UpdateGraphForObstacle(go, broadcastCancToken);
            return true;
        }

A correction of this error will also be included in the nearest update. We apologize for such flaws in the asset code. The update will be released very soon.

No problem.
However, the your fix didnt do it. I figured out what is the problem: you count of all triangles and count the number of processed. It never reaches target count.
I changed to count just game objects, that way it finishes. When i look at scene mode, i see boxes around my objects, which is fine.

But then I do:

 persuer.StopAllAsyncTasks();
                foundRoute.Clear();
                persuer.FindWay(Ship.transform.position, pos,
                    persuer.pathfindingLevel, foundRoute,
                    persuer.selectedPFAlg,
                    new Action(() => { state = Mode.Exit; }),
                    new Action(() => { state = Mode.MovingToBall; }),
                    persuer.trajectoryOptimization, persuer.trajectorySmoothing);

and it never finds path.
I dont know if request for path doesnt get processed or what is wrong…

I have quite complex meshes with lots of hierarchy, maybe that was the problem with triangle count…

I think it would be useful for me to look at your scene. If you are allowed to do this, please send us your scene by mail : support@gracefulalgs.com. We would like to investigate it and find out the cause of the error.
I think it will solve the problem faster than the correspondence on the forum :slight_smile:

Thanks. I will try to prepare something, but for now, I found that complex gameobjects hierarchy (hundreds of object in 4 or more level hierarchy) can cause this. I added tag to ignore them (they are contained in larger gameobject, so it is the same effect)

Feature request. Add tag for ignoring objects when doing HandleAllObstaclesOnScene

Thanks for the feature idea! Honestly, you anticipated our intention. Ignore tags are already being developed and will also be released very soon.

@SoftbrixStudio
This looks like a nice asset I have a few questions, apologies for number, but I am potentially interested.

  1. Would this be a good asset to create at a ‘random’ point in a world, on demand at runtime, a 3d navmesh, for example a 20m cube in the middle of a furnished house, so that any flying AI that entered that zone could path around furniture etc. Then, when finished, delete the mesh and make another elsewhere at another time?
  2. Could you have more than one such mesh in a world at any time?
  3. If 2, could the meshes overlap (assuming my AI are programmed to discriminate), or could you add two meshes together to make one? Or would I delete one and make anew bigger one.
  4. Can I have the navmesh only navigate around assets if they are on a specific layer?
  5. If 4, if meshes are moved between layers is it easy to update the navmesh/is it automatic.
    Lastly, do you have a planned timeline estimate for implementation of local avoidance? And dynamic obstacles?
    Thanks for the help.

Hi, DankP3!
Thanks for the questions, I will try to answer them exhaustively.

1)As I understand it, the first three questions relate to the construction of a navigation graph, which will be used later for pathfinding.

So here, the navigation graph implemented in such a way, that it hasn’t any coordinate constraints. It’s size is not restricted. It’s storages only occupied cells of the space. The cells, that couldnt be finden at graph, are considered as free.

Navigation graph obtaining once at the start of the scene. So, in any time after obtaining a graph, you can serach for a path in any coordinate of the scene space. And all obstacles will be taken into account.

So, the patfinding area is extends over all space of the scene. So no need to rebuild navigation mesh in specific areas of the space.

The obstacles, that appeared after the navigation graph calculation, can be handeled separately and merged to an already constructed graph. The same goes for their disappearing.
2) To define obstacles among all the game object of the scene, special tags are used. So, your conception of the layers may be realised by using of tags groups, that mark gameobjects, that are mmust be taken into account as obstacles.

In-game tag changing will not cause automatic graph updating. It’s need to be executed by manual call of the specific update function.

3)As for local avoidance and dynamic obstacles, currently we are working at this fetures. Theirs release is expected for the end of january or the beginning of the february.

Hope, I understood your questions correctly, and my answers has satisfied you.

If you have any more questions, please ask it.

Thank you very much. I guess i was wondering in a large and complex map if small graphs could be built when needed in specific locations rather than mapping the whole world at the beginning. However, i think you answered my question, a single graph is built for all at the start.
Thanks again,

@SoftbrixStudio may I suggest linking Pathfinder 3D asset store page having a link to this forums? It’ll be useful for potential buyers to know that you are active here and that they’re assured in getting great support here :slight_smile: thanks!

Hi, Mohamed-Anis!
Thanks for the great idea :slight_smile:
Honestly, I was sure that the description contained a link to the forum thread. But, apparently, we still forgot to insert it.

1 Like

@SoftbrixStudio may I know how is local avoidance and dynamic obstacles coming along? Is there an ETA on that?

Thank you!

This feature are currently under development. I do not want to give any exact dates, but according to our estimates, the development will be completed by the end of February - the beginning of March.

Ok! Thank you!

@SoftbrixStudio will your asset support multiple navgraph equivalents? Say I have large airplane that can’t go through narrow corridors while I also have smaller planes that can go through it?

Yes, we have this feature.
Spatial graph, that uses for pathfinding, consist of multiple levels. Each level keeps cells of i’s own size.
The size of the cells at each level is equal to the size of the cells at the previous level plus the size of the cells at zero level multiplied by 0.33. Thus, for a graph with five levels and with a cell size of 1 on the zero level, we obtain the following sequence of cell sizes. 0: 1, 1: 1.33, 2: 1.66, 3: 1.99, 4: 2.32.

The maximum possible number of levels is 15.

Each pursuer can search for a path at any level you wish.

Also can I configure the areas where different objects can move? E.g. Unity’s navmesh allows baking of each navmesh independent of other navmeshes. Do you have such a functionality?