Navigation Baking creates the mesh, but agents don't work

Godot Version

4.2.1 stable

Question

When I use
NavigationServer2D.bake_from_source_geometry_data()
, the mesh is created and it looks fine in debug, but the agent can’t find it for some reason.
nav_region.bake_navigation_polygon()
works, but I need to use the other bake function to create “holes” in the mesh.

How do I make this work?

you will need to reapply the mesh to nav region
check this reply:

and of course when you try to use this NavigationServer2D.bake_from_source_geometry_data()
follow the documentation on how to do it correctly

1 Like

wait what is this doing?

func _process(_delta):
	if Input.is_action_just_pressed("bake_working"):
		bake_working()
	elif Input.is_action_just_pressed("bake_broken"):
		bake_broken()

Do I just call the bake broken function because it’s not working?

i suggest to follow the documentation i sent, the replied i showed is for someone’s issue. he uses the same Nav Region and Tries to use Navigation Server to bake new meshed, but discombobulated on why it needs to reassign the navigation region’s mesh to itself again
the take away is, if you want to use the code, try downloading the project he sent and replace that script code to the one i replied.
Note: if you asked why it needs reassign to itself after post baking it, read the post’s replies, it should be clear why. tl;dr it’s the way it’s to load the mesh back to nav region. the NavigationServer2D.bake_from_source_geometry_data() is never meant to be used with your own pre created NavigationRegion Node anyway. but people tried. Documentation showed the right way to use it. That reply showed how to set the created mesh to pre-created NavigationRegion polygon

the bake broken is the one that uses NavigationServer2D.bake_from_source_geometry_data(), but i fixed so it’s usable now on that reply.