Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

支援不同角色區域許可權

../../_images/nav_actor_doors.png

如果要舉一個遊戲中不同區域存取權限的例子,那通常就是連接房間的門,不同的房間使用不同的導覽網格,不是所有角色、所有時間都能夠進入這扇門。

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.

位元遮罩可以充當一組門鑰匙或者能力,只有與啟用的層中存在至少一個配對,尋路查詢才能夠找出經過這個區塊的路徑。詳見 顯示導覽,介紹了導覽層和導覽遮罩的使用。

../../_images/nav_actor_doorbitmask.png

如果需要,也可以啟用/禁用整個“門”的區塊,但禁用後會阻止所有路徑查詢存取該區塊。

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.

警告

更改導覽層只會影響新的路徑查詢,不會自動更新已有路徑。