TileMapLayer Navigation with Area2D Obstacles

Godot Version

4.3

Question

With 4.3, I migrated over to TileMapLayers. Prior, I had a setup where I was using a NavigationRegion2D over the tilemap (which was in a collision group) to figure out what was navigable.

I also have Area2Ds around the map with collision (also in the collision group that was configured on the NavigationRegion2D).

However, as I have now migrated to 4.3, I was receiving “overlap” errors using this set up. So I have changed to using the TileMapLayer Navigation Layer via painting individual tiles.

In the above setup - how do I mark Area2Ds as not-navigable?

Example:

You can see the TileMapLayer in the background (yellow grass).
This Area2D has a CollisionPolygon2D on it, and is assigned to the group “navigation polygon_source_group”. In the NavigationRegion2D setup, the NavigationPolygon source geometry group name would pick this collision up and automatically carve out this from the NavigationRegion.

However, now that I am not using a NavigationRegion2D, this doesn’t work.

So: what is the intended way to carve out Area2Ds from navigation within TileMapLayer navigation? Can we still use NavigationRegion2D? What is the intended workflow here?

Apologies if this is wordy, it’s a lot to explain!

As an addendum, you can obviously do something like this, to surround it with non-navigable tiles, but this seems not ideal (and not the intended workflow):

As another addendum, this is what it looks like when using NavigationRegion2D and assigning BOTH the TileMapLayer and the Area2D to the navigation_polygon_source_group in the NavigationPolygon

image

This “works” but leads to very odd pathfinding and the following error:

E 0:00:02:0595   sync: Navigation map synchronization error. Attempted to merge a navigation mesh polygon edge with another already-merged edge. This is usually caused by crossing edges, overlapping polygons, or a mismatch of the NavigationMesh / NavigationPolygon baked 'cell_size' and navigation map 'cell_size'. If you're certain none of above is the case, change 'navigation/3d/merge_rasterizer_cell_scale' to 0.001.
  <C++ Source>   modules/navigation/nav_map.cpp:990 @ sync()

This only occurs when adding the TileMapLayer to the navigation_polygon_source_group - so I am clearly misunderstanding some part of the workflow.

Alright, I believe I may have figured this out, for anyone in the future.

I’m not sure if this is the intended flow, but here’s what I did:

  1. I marked all appropriate tiles for navigation with the appropriate painted navigation layer

  2. I DISABLED navigation in the TileSet → Navigation → Navigation Enabled (false)

  3. I am using a NavigationRegion2D with a NavigationPolygon, properties:

  • Parsed Geometry Type: Static Colliders
  • Source Geometry Mode: Group Explicit
  • Source Geometry Group Name: navigation_polygon_source_group
  1. I then did NOT create points for the NavigationPolygon. (THIS WAS THE IMPORTANT STEP)

  2. I made sure my Area2Ds and my TileMapLayer (containing the navigable tiles) were in the navigation_polygon_source_group group

  3. I hit Bake NavigationPolygon in the editor (again, WITHOUT creating any points for the polygon)

  4. The polygon auto-recognized both the TileMapLayer navigation, and carved out the Area2D colliders

Hopefully this is the intended way of usage. The overlap error is gone!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.