NavigationAgent2D - Where is the (TileMap) data source?

Godot Version

4.3 beta 2

Question

Create several TileMaps. Paint certain tiles navigable. NavigationAgent2D can now find paths. i never tell NavigationAgent2D which TileMap to look at (or TileMapLayer in 4.3). So how does it know?

Motivation: Like most people, i’m trying to get NavigationAgent2D to stop slamming people into walls, a feature Godot does not appear to support. In other threads (if i understood correctly) smix8 mentioned having 2 types of TileMaps - one for graphics, one for navigation. You create the latter by squishing the former together. Something like this:

func _ready():
1    for every tileMap:
2        for every tile:
3            if tile is walkable:
4                combined_data [x,y] = walkable
5            if tile has a physics mask:
6                combined_data [x,y] = not walkable
7    var new_nav_mesh = bake(combined_data)
8    navigationAgent2D.nav_mesh = new_nav_mesh

i can probably figure out lines 1-6 but i have no idea how to do line 8.

Note: i don’t use any class other than NavigationAgent2D. i know there are classes for regions and servers and stuff but no tutorial i’ve used (maybe 10 at this point) uses them and NavigationAgent2D seems to “work” without me manually creating/using them.