Jump to content

Accessing pathfinding API


Timberghost

Recommended Posts

Hello, I am trying to access the GeNa API for controlling the pathfinding system. I am able to find some of the function declarations through the project files but none of the definitions are provided, not really sure how to access these. For example I can find a definition for a function named createPath from the PathFinder class, that seems to be exactly what I need but since the definitions are not provided I cannot see what is being executed or see if the code is working as expected besides from visually, which it is not. Beyond this another thing I would like to implement with the pathfinding system is a way to implement additional tests for the points the pathfinding system generates/tests. I could not find anything on this as well, so I would appreciate any more information somebody could provide regarding this. Thankyou, below I will attach the code I am currently using.

I should also note that when building the pathFinding settings it does not seem to reflect inside the editors spline component settings.

        
var spline = gameObject.GetComponent<GeNa.Core.Spline>();
// == Setup Pathfinding Settings == //
        var pathFinding = new GeNa.Core.PathFindingSettings(true, 16, new Vector2(20f, 100), 1);
        pathFinding.m_useExistingCurves = true;
        pathFinding.m_useHeuristicB = true;
        pathFinding.m_splineTravelCost = 0.1f;
        pathFinding.m_maxGrade = 30;
        pathFinding.m_cellSize = 2;


        // == Pathfind between all path points == //
        foreach (List<Point> path in points) {
            Point startPoint = path[0];
            Point endPoint = path[path.Count - 1];
            
            var t = GeNa.Core.GeNaPathFinder.CreatePath(spline, startPoint.node, endPoint.node, pathFinding);
            if (t) { print(startPoint.position + " -> " + endPoint.position); }
        }

 

Link to comment
Share on other sites

Your settings are independent of the Spline path finder settings since you are using the GeNaPathFinder static class directly.

Are your min/max heights on the terrain where the path finder can search between 20 and 100 meters?  The default is between 0 and 5000.
 

Link to comment
Share on other sites

Hello, the maximum terrain height is only to 100, but I did test it with the default settings as well to no noticeable changes.  I noticed this function returns a boolean, what does this represent? Thankyou.

Link to comment
Share on other sites

It does use the PathFinderIgnoreMask of the spline.

If you enable the spline advanced debug (at the bottom of the inspector), any time a path finding  operation fails, it will show Debug output for the search space. (Edit: actually it will always show the search space if debug is enabled).

Link to comment
Share on other sites

path was found as in a created path? Is there any way I can debug this further? like I mentioned I only have the class method declerations but none of the definitions to see how these methods are actually functioning, Would also like to include some custom conditions for the generation of a custom path.  (I will take a look at the debug output!)

Link to comment
Share on other sites

11 minutes ago, Timberghost said:

path was found as in a created path? Is there any way I can debug this further? like I mentioned I only have the class method declerations but none of the definitions to see how these methods are actually functioning, Would also like to include some custom conditions for the generation of a custom path.  (I will take a look at the debug output!)

Yes, if it added nodes and curves to the spline, it will return true, else false.

I will consider custom conditions/Funcs to add to further consideration of a path cell to be considered valid or invalid to move to.  Would you see a need for a Pre and Post check, where Pre check would okay or deny a move without other internal considerations, and Post to possibly override an internal decision? Or a single predicate to make the decision per cell instead of internal decisions?

Link to comment
Share on other sites

For me personally a single predicate per cell would be great, my scenario for this type of system is to avoid points/curves being generated to close to the ocean or in a riverbed, So if I have the abillity to check if the current node is inside of a river or coastline biome I can tell the pathfinding algorithm that it is a false node and a new one needs to be sampled.

Link to comment
Share on other sites

4 minutes ago, Timberghost said:

For me personally a single predicate per cell would be great, my scenario for this type of system is to avoid points/curves being generated to close to the ocean or in a riverbed, So if I have the abillity to check if the current node is inside of a river or coastline biome I can tell the pathfinding algorithm that it is a false node and a new one needs to be sampled.

Perhaps I could send to the predicate the current considerations, so that the default answer to the question could be passed back from the predicate if other considerations "don't care"?

  • Like 1
Link to comment
Share on other sites

Does it work using the standard Spline interface and the same parameters in the editor?

Edit: Try increasing the cell size to 4 - 10.

Edit2: Also, if you set the ignore mask to nothing, then it should go around any mesh colliders that are above the terrain.

Edit3: After examining your code above, I am wondering what the Point class contains, and whether there are multiple GeNaNode and GeNaCurve instances along the path, or does each path (List<Point>) only contain 2 instances of Point.

Link to comment
Share on other sites

3 hours ago, Clyde said:

Does it work using the standard Spline interface and the same parameters in the editor?

Edit: Try increasing the cell size to 4 - 10.

Edit2: Also, if you set the ignore mask to nothing, then it should go around any mesh colliders that are above the terrain.

Edit3: After examining your code above, I am wondering what the Point class contains, and whether there are multiple GeNaNode and GeNaCurve instances along the path, or does each path (List<Point>) only contain 2 instances of Point.


Actually I have intresting results when working with the pathfinding in editor through the Spline component, I have noticed that if I place down nodes, that are not next to each other the pathfinding does not seem to take place, only when the nodes are close to each other, will the pathfinding take place. Here are my current values. and a example of the environment. 

image.png.e986a1ad1aa09e3b22aa26890c532ff3.png

Here is an example of four nodes that I placed using the editor, the bottom two nodes had a curve created using the pathfinding, the top two nodes I attempted to use the pathfinding but it could not create any curves. The distance here looks similar, I will post a top down showing the distance, but these are not great distances.

image.thumb.png.38e29f7f553b1e1c26b269e79d0f28ba.png


image.png.22a441e2b245f04e130e0d58033fde52.png

Right now I dont believe the methods are at fault and my configuration is incorrect, one thing I have noticed as well is that the placement of the nodes is being finicky, sometimes the node will be registered when I left click and other times a transform Gizmo appears but the node itself is not registered into the spline.

For the Point class, it contains the gena Node, the position and some other data such as the current biome and steepness of the terrain to consider if the point is a valid one. some of the test cases we were talking about yesterday. each path only has two instances of the point.

Link to comment
Share on other sites

Yeah, I know this was working before. I have tried re-importing the asset now I will try to create a new project and test. Not sure what could be causing this

  • Like 1
Link to comment
Share on other sites

3 minutes ago, Timberghost said:

Yeah, I know this was working before. I have tried re-importing the asset now I will try to create a new project and test. Not sure what could be causing this

I have noticed that under certain circumstances the "Failed to Find Path" dialog box does not come up, when using the editor, but a message is displayed in the Console.

Link to comment
Share on other sites

So I was able to succesfully get it working when creating a new project. I tried resetting the terrain in my other project to no success. Is it possible to that there is a cache outside of the procedural worlds folder that could have invalid data? I have tried reimporting the asset multiple times to no success, I will keep trying to look for differences between the two projects.

Link to comment
Share on other sites

  • 4 months later...
On 7/15/2022 at 7:16 AM, Timberghost said:

So I was able to succesfully get it working when creating a new project. I tried resetting the terrain in my other project to no success. Is it possible to that there is a cache outside of the procedural worlds folder that could have invalid data? I have tried reimporting the asset multiple times to no success, I will keep trying to look for differences between the two projects.

Hey @Timberghost,

Could you please confirm if you are still running into the same issue with the latest version of GeNa Pro?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Tell a friend

    Love Canopy - Procedural Worlds? Tell a friend!
  • Need help?

    We work with some of the biggest brands in global gaming, automotive, technology, and government to create environments, games, simulations, and product launches for desktop, mobile, and VR.

    Our unique expertise and technology enable us to deliver solutions that look and run better at a fraction of the time and cost of a typical project.

    Check out some of our non-NDA work in the Gallery, and then Contact Us to accelerate your next project!

×
×
  • Create New...