Work in progress
Godot documentation is being updated to reflect the latest changes in version
4.0. Some documentation pages may
still state outdated information. This banner will tell you if you're reading one of such pages.
The contents of this page are up to date. If you can still find outdated information, please open an issue.
Support different actor area access¶
A typical example for different area access in gameplay are doors that connect rooms with different navigation meshes and are not accessible by all actors all the time.
Add a NavigationRegion at the door position. Add an appropriated navigationmesh the size of the door that can connect with the surrounding navigationmeshes. 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" navigationmesh.
The bitmask can act as a set of door keys or abilities and only actors with at least one matching and enabled bit layer in their pathfinding query will find a path through this region. See Using NavigationLayers for more information on how to work with navigation layers and the bitmask.
The entire "door" region can also be enabled / disable if required but if disabled will block access for all path queries.
Prefer working with navigation layers in path queries whenever possible as enabling or disabling navigation layers on a region triggers a performance costly recalculation of the navigation map connections.
Changing navigation layers will only affect new path queries but not automatically update existing paths.