Remove a NavigationPolygonInstance (at a certain point) created by a TileMap

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Christopher Dumas

Hi everyone, so I am working on a game that requires modification of the tilemap in-game, indirectly. I’m placing StaticBodies into the screen (barricades and other items) and I need my AIs to be able to pathfind around them. I’m using a Navigation2D instance, with the TileMap and the StaticBodies added as children to that, and I’ve added NavigationPolygonInstances to the tiles in the tilemap using the new (Godot 3.1) TileSet editor. Right now, when you place a StaticBody into the scene (snapped to the map’s grid, but not in the map), I replace the tile under it with a version of the same tile that doesn’t have a NavigationPolygonInstance on it. This means that I have to have duplicate versions of every single floor tile, though, and it’s really not great. Is there any way to dynamically access the TileMap’s navigation mesh to modify it at runtime?

Thanks in advance for your help,

  • Christopher

I have the exact same problem, if anyone has a solution I’d be happy to hear it !

Nevaran | 2019-12-05 14:03

:bust_in_silhouette: Reply From: Zylann

I think replacing the tile is the only way at the moment. You could eventually mitigate the problem by having two tilemaps, one of them only holding navigation tiles, and the other for visuals. This could in turn be automated with a script so you could keep designing them all at once but separate them in a baking tool / at runtime.
Or you could make it so those tiles in particular are actually individual nodes?