Access Control

Access Control

Create restricted access areas and interactable objects that respond based on if the player has been granted access or not.

This package was intended to be used by the Events system and works well with OnInteract, OnTriggerEnter and OnTriggerExit. It can also be used via code.

Ideas on how to use this package:

  • Create a door that needs a key to open.
  • Limit interacting with an entity to one player at a time.
  • Create an area for each player similar to the tycoon blueprint.
  • One-time use items, a key that only opens a door once.

Components

Access Control Authenticator

Use one authenticator for each entity. The authenticator asks the Enrollment script if the user has access and will automatically find the nearest enrollment script.

It first looks for the Enrollment script on the same entity. If the Enrollment script is not found on the same entity, it will continue to search each parent entity until found.

Functions:

  • Authenticate - It will fire one of two events when called. On Authentication Success or On Authentication Failed.
    All parameters passed into Authenticate() will be forwarded to the events.
    Usage: Use with the entity’s On Interact

Events:

  • On Authentication Success
    Usage: A door that needs a key to open. Call the door script’s Toggle or Open function.

  • On Authentication Failed - Fired when Authenticate fails.
    Usage: Tell the player they can’t use this entity.

Access Control Enrollment

The Enrollment component keeps track of whether a player has access. One Enrollment component can be used with many authenticators.

Options:

  • Allow Multiple Players - Allow multiple players to request access to this enrollment script.

Functions:

  • RequestAccess - When called, it will fire one of two events. On Enrollment Granted or On Enrollment Denied. If the player already has access, no event will fire.
    All parameters passed into RequestAccess() will be forwarded to the events.
    Usage: A key that opens a door. Set the key’s On Interact to RequestAccess.
    Usage: One player per area. Create a trigger and set the On Trigger Enter to RequestAccess.

  • RevokeAccess - If the player/user were previously granted access, it would fire the event On Enrollment Revoked. RevokeAccess is called OnUserLogout.
    All parameters passed into RevokeAccess() will be forwarded to the events.
    Usage: One player per area. Set the On Trigger Exit to RevokeAccess.

Events:

  • On Enrollment Granted - This event is fired when the player is granted access.
    Usage: Change an indicator from available to unavailable.

  • On Enrollment Denied - This is fired when the Allow Multiple Players option is disabled and a player requests access, but another player was granted access earlier.
    Usage: Tell the player that this area is already in use.

  • On Enrollment Revoked - This event will not fire if the player does not have access.
    Usage: Change an indicator from unavailable to available.

Examples:

Basic Door and Key

The Door:

  • Install Door Package.
    1_DoorPkg

  • Place the Game Round Door template into the world.
    2_Templates

  • Add the Access Control Enrollment template to the door.

  • Add the Access Control Authenticator to the door.
    3_Door

  • Create a new On Authentication Success binding and add Door/doorScript/Toggle.

  • Set the door’s On Interact to accessControlAuthenticatorScript/Authenticate function.
    5_OnInteract

The Key:

  • Place a key mesh into the world. Set the On Interact to accessControlEnrollmentScript/RequestAccess.
    6_Key

Testing:

  • The door won’t open if the player hasn’t interacted with the key.
Demo Game(Remix)

https://launch.crayta.com/play/fcd3vz9c

1 Like

June 3rd, 2022
Version 3

  • Events will now forward all parameters instead of just the player.
  • Updated the tooltips.

Version 4

  • Fixed tooltip error.