我在godot中有一个tilemap,但是所有的tile都是障碍物并提供碰撞。只有没有任何瓷砖的单元格可以步行。我现在正在尝试通过 Navigation2D 节点添加导航。据我所知,没有办法告诉它“一切都可以步行,但不是这些瓷砖在哪里”(只能说“瓷砖的这一部分是可步行的”,但在我目前的设置中没有瓷砖步行空间)。
作为一种解决方法,我尝试将没有瓦片的每个单元格设置为“虚拟瓦片”,该“虚拟瓦片”可以使用以下代码完全步行:
func _ready():
for x in size.x:
for y in size.y:
var cell = get_cell(x, y)
if cell == -1:
set_cell(x, y, WALKABLE)
但 Navigation2D 节点无法识别这些图块。如果我手动放置WALKABLE
瓷砖,一切都会按预期工作。
我想我可能遇到了这个问题,需要打电话update_dirty_quadrants()
,但这并不能解决问题。
我用 3.0.6stable、3.1Alpha2 和最近的提交 9a8569d(由 godotwild 提供)尝试了这个,结果总是一样的。
无论如何都可以使用 tilemaps 进行导航,而无需事先手动放置每个图块?