• 2D
  • Issue with Navigation 2D and TileMap

(Godot 3.3.2 stable, Windows 10)

I have a TileMap under a Navigation node, generating simple paths for my enemies to move around in. I have an issue where sometimes, depending on position of the enemy, the pathing will suddenly cut through a space where there's no navigation, as you can see in the GIF:

The white transparent lines are Line2D's using navigation data. You can see that after updating close to the corner, it suddenly goes through, while the other navigations (from 3 other enemies) keep going around.

Is this a known issue?

I don't think it's related, but I'm using a 3*3 minimal autotile, none of those have navigation on them and so I change all empty tile spots with one that has navigation on it.

func _ready() -> void:	
	# Find the bounds of the tilemap (there is no 'size' property available)
	var bounds_min := Vector2.ZERO
	var bounds_max := Vector2.ZERO
	for pos in get_used_cells():
		if pos.x < bounds_min.x:
			bounds_min.x = int(pos.x)
		elif pos.x > bounds_max.x:
			bounds_max.x = int(pos.x)
		if pos.y < bounds_min.y:
			bounds_min.y = int(pos.y)
		elif pos.y > bounds_max.y:
			bounds_max.y = int(pos.y)

	# Replace all empty tiles with the provided navigation tile
	for x in range(bounds_min.x, bounds_max.x):
		for y in range(bounds_min.y, bounds_max.y):
			if get_cell(x, y) == -1:
				set_cell(x, y, 0, false, false, false, Vector2(8,5))

	# Force the navigation mesh to update immediately
	update_dirty_quadrants()

Navigation has a lot of issues in 3.x, and many of these will not be fixed until 4.0 is released.

If the enemy can jump, I'd probably make it jump whenever it hits a wall.