Skip to content
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

get_simple_path() navigates to unconnected navmesh #41546

Closed
hodgej opened this issue Aug 26, 2020 · 4 comments
Closed

get_simple_path() navigates to unconnected navmesh #41546

hodgej opened this issue Aug 26, 2020 · 4 comments

Comments

@hodgej
Copy link

hodgej commented Aug 26, 2020

Godot version:
3.2 stable

Issue description:
get_simple_path will navigate to a navmesh very far away, and cause the node navigating to go outside the current navmesh. I'm trying to have each node linger about it's dedicated island, but they keep navigating crazy paths. Here's an example

You can see one of the black dots (which are the nodes doing the navigation) navigate across navmeshes, doing a crazy long path, going outside the bounds of the navmesh, to a relatively close point inside the intended navmesh "island".
Even if I surround each island with other tiles, creating one large navmesh, it still does crazy paths: Example of this

A simple fix for this issue would be allowing the user to specify what navmesh the node is allowed to navigate on in the get_simple_path() function.

Steps to reproduce:
Create separate islands with a tilemap navmesh (different tiles per island), place several nodes who have a simple script creating paths and following them, but only tell the nodes to navigate to random tiles of the type they are dedicated to. In order to navigate to a tile inside their current tilemap, a path is generated to another island navmesh and back.

@Calinou
Copy link
Member

Calinou commented Aug 26, 2020

@vpellen
Copy link

vpellen commented Aug 27, 2020

I believe this is caused by Navigation2D::get_simple_path using Geometry::is_point_in_triangle, which returns false for points on the edges of triangles, leading to endpoints that intersect triangle edges within the navmesh to be counted as "outside the navmesh". It causes weird snapping issues. It can potentially be dealt with if you know exactly where those triangle boundaries are and you offset your endpoints slightly, but it's still a major pain in the ass.

@hodgej hodgej closed this as completed Sep 4, 2020
@hodgej hodgej reopened this Sep 4, 2020
@hodgej
Copy link
Author

hodgej commented Sep 4, 2020

Apologies for that, mistakenly clicked "close issue".

@smix8
Copy link
Contributor

smix8 commented Jun 1, 2022

@Calinou
@akien-mga
This weird pathfing issue was for the old 2D navigation before 3.5 and is no longer valid.

In Godot 4.0 and 3.5 the 2D navigation uses the same navigationmesh based pathfinding as 3D behind the scene. As long as the NavigationPolygon is created correctly this pathfinding issue no longer happens. In fact the 2D paths have the same path optimization as 3D now.

@akien-mga akien-mga added this to the 3.5 milestone Jun 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants