Exception when building path for specific route

  • A* version: 4.2.17
  • Unity version: 2022.3.14f1

I have three groups of PointNodes, each manually connected using the Link script. However, when I try to create a path starting and ending near the B1 group, the system generates a path using the 2F group instead.

Only a few specific routes cause this issue; most of the time, the system correctly distinguishes the proper floor.
How can I configure the settings to exclude specific node groups or adjust the setup to fix this issue?

My pathfinding script implementation

        private async UniTask<Path> ConstructPathAsync(Vector3 start, Vector3 end, OnPathDelegate callback=null)
        {
            Path currentPath = ABPath.Construct(start, end, callback); 
            AstarPath.StartPath(currentPath); 
            currentPath.BlockUntilCalculated(); 
            await UniTask.Yield();
            seeker.PostProcess(currentPath); 
            currentPath.Claim(this);
            return currentPath;
        }

The green connection lines in this image represent the PointNodes, the cubes indicate the start and end points I set, and the blue path shows the result after building the route.

Graphs and AIPath settings


It took me longer than I’d like to admit to realize that B1 and 2F were floors haha.

Could you possibly change the cost of going from floor to floor using costFactor?

(Also your title mentions an exception, I’m not seeing any in the post though?)

Sorry, I forgot to explain that the term refers to floors.

I later added a cost factor for moving between floors, which resolved the issue with the specific path mentioned in my original post. However, I’m now encountering other examples.

As shown in the diagram, both my start and end points are on the first floor, but the generated blue path still goes up to the second floor. I noticed this happens when the start and end points are positioned along a line between two PointNodes. If there happens to be another PointNode on a different floor between them, it leads to this result.


Would modifying the nearestNodeDistanceMode to Connection improve this issue?
Is this feature unable to fix the path? postProcessPath I have adjusted the settings to Node Connection.

Thank you very much for your reply!

From what you described and what I’m reading changing it to Connection may in theory work- have you had the chance to attempt it? It sounds like it may not have fixed your issue directly?

I also want to make sure I’m understanding the image correctly- the unit is on the first floor, but the start path is generating on the second floor above them? If that’s correct then yeah according to the documentation that should be the fix. Let us know if that helps.

I haven’t purchased the Pro version yet, so I’m unable to test that feature.

Yes, you understood correctly. The start and end points are on the first floor, but the generated path ends up on the second floor. This often happens when the starting point is located between two PointNodes connected by a line, and there happens to be a PointNode on the second floor along that line.

I mainly wanted to ask if purchasing the Pro version nearestNodeDistanceMode could resolve this issue since I can’t test it at the moment.

Thank you very much for your reply!

Yes, that will likely resolve your issue.

1 Like

Ahh, my mistake! Yeah as aron says I’m pretty confident it would, too. If not I’m still here to help you find a solution :+1:

1 Like

@aron_granberg @tealtxgr
Upgrading to the Pro version has resolved the issue. Thank you very much for your help!

1 Like

Hurray! Glad it helped, hope you enjoy the other pro features as well :slight_smile:

1 Like