Closed spikeyarmaku closed 9 months ago
The NavigationPolygon has by default an agent_radius
of 10 pixel.
In the test project the available surface is too small so there is no navigation mesh surface left after the offset is done.
So either increase the available, traversable surface or reduce the agent radius on the NavigationPolygon.
I rewrote the code by multiplying every coordinate by 10, but the result is the same. For convenience's sake, here is the code I tried:
func _ready():
var rect1 = [Vector2(0, 0), Vector2(1000, 0), Vector2(1000, 1000), Vector2(0, 1000)]
var rect2 = [Vector2(-200, -200), Vector2(800, -200), Vector2(800, 800), Vector2(-200, 800)]
var src = NavigationMeshSourceGeometryData2D.new()
var navpoly = NavigationPolygon.new()
src.add_traversable_outline(rect1)
src.add_obstruction_outline(rect2)
NavigationServer2D.bake_from_source_geometry_data(navpoly, src)
$NavigationRegion2D.navigation_polygon = navpoly
I also tried setting the agent radius to 1, but that also didn't change anything.
Bakes just fine but with that size you really need to zoom out to see the navigation mesh in the bottom right corner.
You're right. Turns out I forgot to switch "Visible navigations" on when I restarted Godot.
Turns out I forgot to switch "Visible navigations" on when I restarted Godot.
Happens to the best of us.
Closing as issue seems to be solved, feel free to reply if it isn't.
Godot version
v4.2.stable.official [46dc27791]
System information
Godot v4.2.stable - Windows 10.0.19045 - Vulkan (Mobile) - dedicated Radeon RX Vega (Advanced Micro Devices, Inc.; 31.0.21905.1001) - AMD Ryzen 5 3600 6-Core Processor (12 Threads)
Issue description
I want to create a navmesh from code. The setup is this:
Both rectangles have the same winding.
Expected result: an L-shaped traversable area Actual result: an empty navmesh
This is the code that is responsible for creating the navmesh:
Steps to reproduce
Debug
->Visible navigation
There is a Line2D surrounding the area where the navmesh should appear.
Minimal reproduction project
polygon2d_bug.zip