NavigationRegion2D doesn't initialize its navigation_mesh
correctly resulting in an error with a cell_size
mismatch
#83570
Labels
Milestone
Godot version
4.2 beta1
System information
Windows 10
Issue description
I was trying out the new 2D Navigation mesh baking features (great stuff, btw!) and immediately ran into an error after creating a
NavigationRegion2D
and a correspondingNavigationPolygon
(all in the editor/inspector) :I haven't changed any of the
cell_size
settings anywhere and I can't even set thecell_size
of theNavigationPolygon
to 0.25, since the inspector for that is integer based. So I had a look at the code and the culprit seems to be in the constructor of theNavigationPolygon
:The
navigation_mesh
is instantiated with its default values (cell_size
being 0.25!) and the real initialization, where thecell_size
is set, is then not executed, becausenavigation_mesh
is not null:So I removed the
navigation_mesh
instantiation from theNavigationPolygon
constructor and went on with my testing without any further hitch. As far as I knownavigation_mesh
is only accessed throughget_navigation_mesh()
, where it is then instantiated lazily, so the instantiation in the constructor is not needed. I implemented and tested a whole navigation system for our game based on theNavigationRegion2D
after that change and haven't noticed any problems (but I am only creating the navigation polygon at runtime viaNavigationServer2D.bake_from_source_geometry_data_async
, so maybe there are problems in other use cases 🤔).I just drafted a PR: #83568
Steps to reproduce
Minimal reproduction project
A reproduction project isn't really necessary, since the steps are so simple, but here is one anyway:
NavigationRegion2DTest.zip
(when you open the scene.tscn, you'll get the error as well)
The text was updated successfully, but these errors were encountered: