Up to date
This page is up to date for Godot 4.2
.
If you still find outdated information, please open an issue.
支持不同角色区域权限¶

如果要举一个游戏中不同区域访问权限的例子,那通常就是连接房间的门,不同的房间使用不同的导航网格,不是所有角色、所有时间都能够进入这扇门。
Add a NavigationRegion at the door position. Add an appropriate navigation mesh the size of the door that can connect with the surrounding navigation meshes. In order to control access, enable / disable navigation layer bits so path queries that use the same navigation layer bits can find a path through the "door" navigation mesh.
位掩码可以充当一组门钥匙或者能力,只有与启用的层中存在至少一个匹配,寻路查询才能够找出经过这个区块的路径。详见 使用 NavigationLayer,介绍了导航层和导航遮罩的使用。

如果需要,也可以启用/禁用整个“门”的区块,但禁用后会阻止所有路径查询访问该区块。
Prefer working with navigation layers in path queries whenever possible as enabling or disabling navigation layers on a region triggers a costly recalculation of the navigation map connections.
警告
更改导航层只会影响新的路径查询,不会自动更新已有路径。