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

NavigationRegion3D saved "disabled" don't work when enabled in script #83364

Closed
Malcolmnixon opened this issue Oct 15, 2023 · 1 comment · Fixed by #83365
Closed

NavigationRegion3D saved "disabled" don't work when enabled in script #83364

Malcolmnixon opened this issue Oct 15, 2023 · 1 comment · Fixed by #83365

Comments

@Malcolmnixon
Copy link
Contributor

Godot version

4.2-beta.1

System information

Windows 11, Vulkan Mobile, NVidia RTX 3070 TI

Issue description

I have numerous "bridges" (meshes with NavigationRegion3D) that start life disabled (NavigationRegion3D.enabled = false).

In Godot 4.1 I could enable these bridges in script when the player triggered an action, and the NavigationRegion3D would correctly enable with edge connections allowing NPCs to walk across the bridge.

In Godot 4.2 if the NavigationRegion3D is saved disabled then enabling/disabling fails to enable edge connections. I suspect the bug may have been introduced by #77191 in NavigationRegion3D::_region_enter_navigation_map. This function only registers the region with the world-map if the region is enabled when it enters the tree. Enabling at a later time does not register the region.

Steps to reproduce

Attached is a simple demo project. When loaded the main scene shows the following three navigation regions and their edge connections:
image

Toggling the enable on region 1 works as expected:
image

Save the scene with region 1 disabled; then close and reopen it:
image

Toggling the enable on region 1 fails to enable the edge connections:
image

Minimal reproduction project

NavRegionDisabledBug.zip

@Malcolmnixon
Copy link
Contributor Author

Inspecting NavigationRegion3D::set_enabled() shows that it implements enabling and disabling of regions via NavigationServer3D::get_singleton()->region_set_enabled(region, enabled);.

As such I suspect NavigationRegion3D::_region_enter_navigation_map() should always register the region with the map using the NavigationServer3D::get_singleton()->region_set_map(region, xxx);, but should follow it up with a NavigationServer3D::get_singleton()->region_set_enabled(region, enabled); call.

Malcolmnixon added a commit to Malcolmnixon/godot that referenced this issue Oct 15, 2023
This PR fixes issue godotengine#83364 by always registering the region when it enters the tree, and instead using region_set_enabled to control whether its enabled. The same logical changes have been applied to NavigationRegion2D.
@AThousandShips AThousandShips added this to the 4.2 milestone Oct 15, 2023
ProbablyWorks pushed a commit to ProbablyWorks/godot that referenced this issue Oct 22, 2023
This PR fixes issue godotengine#83364 by always registering the region when it enters the tree, and instead using region_set_enabled to control whether its enabled. The same logical changes have been applied to NavigationRegion2D.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants