-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Strange pathfinding with NavigationPolygon #15919
Comments
!!!!!!!!! I have the same problem! Was about to post the issue, but it's very similar! It also only happens from that position, from the upper right side of the square to the down side of the square and from the inverse route too. If I do it from the left side, it has no problems. Godot 3.0 final |
@hinasis |
In my case I did the navpoly by code, so they all were completely straight, I don't belive it's the problems. Hope they fix the Nav2D.. P.S: This issue is so buried, it's posible they never read it. |
I added a bit of code to visualize the polys of the NavMesh in the example project, and noticed two problems: The A* cost heuristic is not admissible, it may overestimate the actual distance: godot/scene/2d/navigation2d.cpp Lines 390 to 405 in a74e151
... since it considers the distance from the poly center point to the end point. This is a big problem here, as the poly with the shortest route is comparatively big, with a center that's far away from the optimal route. After fixing that, the algorithm still isn't quite ideal, since it does this: godot/scene/2d/navigation2d.cpp Lines 417 to 423 in a74e151
The algorithm assumes that the shortest distance to another poly is through the nearest point on the edge to that poly, disregarding the fact that this may make the overall distance longer. That's a problem with the algorithm itself, since it first finds a (non-optimal) path, and then tries to optimize it using string pulling. I suppose that's why the function is called EDIT: I looked at the Unity documentation and it seems that it suffers from the same (or a very similar) problem:
|
Maybe instead of the poly center, it should use the point closest to the target point within the poly to compute distance, that may make more sense, what do you think? |
Godot version:
Godot 3.0 final
OS/device including version:
Windows 10 x64
Issue description:
![bad_navigation](https://user-images.githubusercontent.com/15133020/35189497-7d1df0c6-fe43-11e7-940b-c48653825a41.png)
Using Navigation2D's get_simple_path() produces strange and inefficient paths, especially when navigating around inside polygons. For example:
The dots represent the path connecting the sprite to the mouse, for some reason it decides to go around the square even though it could reach the mouse by going straight towards it.
Steps to reproduce:
Just create a hole in a NavigationPolygon and try to path near it. Sometimes the path isn't too inefficient, it depends on the exact shape of the polygons.
Minimal reproduction project:
navigation.zip
The text was updated successfully, but these errors were encountered: