godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.16k stars 97 forks source link

NavigationRegion nodes should warn you that they won't work until baked #9070

Closed TDuffinNTU closed 7 months ago

TDuffinNTU commented 8 months ago

Describe the project you are working on

a tower defence-like game where certain units can move freely within a 2d region

Describe the problem or limitation you are having in your project

I spent over an hour debugging why my navigation agents didn't move, only to discover the "bake navigation polygon" button that I didn't notice before.

This isn't helped by the fact that there are no warnings that you're trying to navigate with an unbaked nav. region. However, it WILL throw an error if navigation is attempted before said node is synchronized (even if it has no data to sync!).

Symptoms for an unbaked nav mesh are hard to diagnose if you've not used the feature before, especially with the minimal documentation available.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

A warning icon like used for character body nodes that lack collision should be shown when a navigation region hasn't been baked yet. This would help signpost users to the "bake navigation" button and avoid searching for ages and following contradictory documentation suggestion the real issue is not deferring until the 2nd physics frame.

Better yet, if Godot detects you've called get_next_path_position whilst you have no baked navigation regions in the scene tree, an error/assertion should be thrown.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

  1. Warning icon, shown when a NavigationRegion node has no baked mesh. Similar to CharacterBody2D without collision: image

  2. Throw an exception when get_next_path_position is called and Godot cannot find a baked navigation mesh to use.

If this enhancement will not be used often, can it be worked around with a few lines of script?

Better documentation for how to use the node within the editor would be good. Right now there's not much useful info on setting up navigation "step by step"

Is there a reason why this should be core and not an add-on in the asset library?

It's a core Godot node.

smix8 commented 8 months ago

Better documentation for how to use the node within the editor would be good.

There is a section for the NavigationRegion2D navigation mesh baking here https://docs.godotengine.org/en/latest/tutorials/navigation/navigation_using_navigationmeshes.html#baking-a-navigation-mesh-with-a-navigationregion

smix8 commented 7 months ago

With PR https://github.com/godotengine/godot/pull/87504 NavigationRegion2D now auto-bakes by default after a delay.

TDuffinNTU commented 7 months ago

Appreciate the work on this. For some reason I never could find that linked documentation when learning about NavMesh2D but I'm thankful this is being improved! :)