reckfellENGINE

Area access: masks and closing passages

Filter by capabilities without incorrect bitwise conditions.

On this page

Use query masks for different permissions on the same geometry, rather than rebaking for every key. Character size is a separate concern: see clearance variants.

Label a passage

The executed fixture has rooms at x=0–10 and x=20–30 and a connecting passage at x=10–20, all with y=0–10. Rooms use public layer 1; the passage uses staff layer 2. Geometry connects on one map.

Save DoorAccess.cs:

C#
public static class DoorAccess
{
    public const uint Public = 1u;
    public const uint StaffDoor = 2u;
    public static uint QueryMask(bool hasDoorAccess) =>
        Public | (hasDoorAccess ? StaffDoor : 0u);
}

Assign DoorAccess.StaffDoor to passage NavigationLayers and DoorAccess.Public to rooms. Supply DoorAccess.QueryMask(hasDoorAccess) to a new MapGetPath navigationLayers parameter or NavigationAgent2D.NavigationLayers.

Verified: mask 1 does not complete the route from (5, 5) to (25, 5); mask 3 admits rooms and passage. Mask 2 alone is insufficient: it permits the passage but not public rooms.

Bit overlap rather than a condition system

A region is eligible when its mask and the query share at least one bit. Several region bits do not require every key. If a door needs both a key and a completed quest, calculate hasDoorAccess using gameplay rules before selecting the mask.

Do not also assign the public layer to a staff door that should block ordinary characters: any shared public bit admits it. Layer numbers and masks differ; see bit rules.

Closing and revoking access

A query-mask change affects a new search. Refresh an existing path array and handle unreachability. Region enable/disable changes apply after map publication.

Disable a door region to close it for everyone. In the check, RegionSetEnabled(doorway, false) removes the complete route even for the staff mask. An old array remains unchanged. Disabling navigation does not create a door physics collider either.

Path-query permission is not final permission to perform a game action. Validate access when actually opening or traversing the door: a character may hold an old route, be relocated or be controlled by a network client.

Diagnose access problems

  • Everyone can use the staff passage: check unwanted public bits or a bypass region.
  • A key exists but no route does: include ordinary rooms and the passage in the query mask; inspect map and connections.
  • Revocation does not stop a character: refresh the retained route and separately stop the forbidden action.
  • Each character changes the whole level: prefer masks on new queries to repeatedly toggling a shared region.

Executed 2D checks cover the exact helper, three masks, closing the shared passage and a retained old route. Gameplay key/quest checks, physical doors, network permissions and 3D passages are outside this suite's coverage.

Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.