godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.11k stars 21.16k forks source link

Navigation using get_simple_path ignores partially open tiles ; "Condition !nm.linked is true" #7732

Closed sylva-nia closed 5 years ago

sylva-nia commented 7 years ago

Operating system or device - Godot version: Windows 10 / GD 2.1.2

Issue description: Pathfinding using Navigation2D with a child TileMap whose tiles contain NavigationPolygons+Instances: When invoking get_simple_path from the character (RigidBody2D > AnimationPlayer, 2 Sprite layers, CollisionShape2D, RayCast2D), any tiles which are not fully open are ignored. EG: In a build where stair tile NavPolygons did not include the leftmost and rightmost pixels (x of -8 or 8, leaving a 14 x 16 px NavPoly), function returned an empty path. Still happens with left/right and top/bottom bordered tiles, which use similar NavPolygons. My project uses 16x16 map tiles and a 16x16 character. Shrinking the character sprites to below 14x14 did not solve the issue.

Possibly related is this error, which appears in the log/terminal when the function fires: "ERROR: Navigation2D::_navpoly_unlink: Condition ' !nm.linked ' is true. At: scene\2d\navigation2d.cpp:147"

Additional Information: Both the character sprites and tilemap are set to scale 2x2, though the issue still occurred at 1x1. Tiles also contain StaticBody2D and CollisionPolygon2D to prevent accidentally crossing over navigation boundaries and allow physics interactions. As get_simple_path produces some less-than-efficient paths when there are no obstacles, I'm using the RayCast to check for collisions to target and just setting the path to the target point if there aren't any. Oddly enough, since I'm creating the Nav and Collision polygons programmatically in a tool script, they don't actually appear in the scene graph.)

tilescene-editor

bojidar-bg commented 7 years ago

I think Navigation2D expects you to map the walkable area, rather than the unwalkable area (though this might change in later versions).

sylva-nia commented 7 years ago

If you look at the screencap, I did that - the green (walkable) areas are navigation polygons, and the red/other colors are collision polygons.

bojidar-bg commented 7 years ago

@niodyn Ouch, sorry, I assumed the opposite...

reduz commented 7 years ago

The polygon points have to match for the connectiin to happen. I was thinking maybe this could be improved to detect edge overlaps instead

On Feb 6, 2017 13:59, "Bojidar Marinov" notifications@github.com wrote:

@niodyn https://github.com/niodyn Ouch, sorry, I assumed the opposite...

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/godotengine/godot/issues/7732#issuecomment-277743888, or mute the thread https://github.com/notifications/unsubscribe-auth/AF-Z29808tw24WNyvi0fwto_-dqtBsD7ks5rZ1FzgaJpZM4L3pmR .

sylva-nia commented 7 years ago

@reduz Ahh, I see. That's counter-intuitive, but certainly something I can work around. Yes, I think edge overlaps would make more sense to most people. Any ideas about the !nm.linked message, is it directly related to the edges not matching up?

bojidar-bg commented 7 years ago

@niodyn It comes from scene/2d/navigation2d.cpp:147. I guess it happens when a navpoly has absolutely no common points with the rest of the tree, or something like that.

sylva-nia commented 7 years ago

Hmm... Is it really necessary to constantly output it as an error, then? It bogs down my game and floods the debugger...

Ryan-Ellingson commented 7 years ago

Is there a way to suppress certain errors?

kubecz3k commented 6 years ago

First of all thank you for your report and sorry for the delay.

We released Godot 3.0 in January 2018 after 18 months of work, fixing many old issues either directly, or by obsoleting/replacing the features they were referring to.

We still have hundreds of issues whose relevance/reproducibility needs to be checked against the current stable version, and that's where you can help us. Could you check if the issue that you described initially is still relevant/reproducible in Godot 3.0 or any newer version, and comment about its current status here?

For bug reports, please also make sure that the issue contains detailed steps to reproduce the bug and, if possible, a zipped project that can be used to reproduce it right away. This greatly speeds up debugging and bugfixing tasks for our contributors.

Our Bugsquad will review this issue more in-depth in 15 days, and potentially close it if its relevance could not be confirmed.

Thanks in advance.

Note: This message is being copy-pasted to many "stale" issues (90+ days without activity). It might happen that it is not meaningful for this specific issue or appears oblivious of the issue's context, if so please comment to notify the Bugsquad about it.

akien-mga commented 5 years ago

Our Bugsquad will review this issue more in-depth in 15 days, and potentially close it if its relevance could not be confirmed.

As there was no update since the previous post, we close this issue.

If it is still relevant in the way it was described and discussed above, please comment to ask for it to be reevaluated. If it is only partly relevant, or if the original issue has changed, it would be better to open a new issue (potentially referring to this one) focused on the current state.