SmartKeyHolder
The SmartKeyHolder is a component that forms the core of the interaction system with doors in the game environment. It defines the ability to control smart doors and defines how and when your in-game
Last updated
Was this helpful?
The SmartKeyHolder is a component that forms the core of the interaction system with doors in the game environment. It defines the ability to control smart doors and defines how and when your in-game
Last updated
Was this helpful?
The SmartKeyHolder
has the ability to interact with a SmartDoor
when your character is close enough to it, based on a pre-defined reach distance. This distance can be specified and adjusted as per individual game requirements.
SmartKeyHolder
can hold multiple keys (currentKeys
) and potentially use those keys to unlock or perform special actions on different SmartDoor
objects.
SmartKeyHolder
has a mechanism to auto-open the doors when the character is in reach. This can be enabled or disabled by setting the openDoorOnReach
property.
The SmartKeyHolder
also supports user input to manually open (KeyCode.E
) or close (KeyCode.R
) doors when within range.
This setting allows the developer to visualize the SmartKeyHolder's
activity in the Unity 3D Editor itself, helping them to debug and understand the SmartKeyHolder's
interactions in the game world.
This component can be attached to any game object, but ideally, it should be attached to the character that will be interacting with various SmartDoor
-compatible doors in your game world. Once attached, you should configure its properties as per your requirements, like setting the maximum reach distance, deciding the raycast’s offset, specifying interaction keys, etc. Once set up, it provides an easy and efficient way to manage door interactions in your Unity game.
This is an array holding references to SmartKey
objects. These objects represent keys that can be used to interact with SmartDoor
objects in the game. Depending on the key used, different interactions or behaviors can take place with the SmartDoor
.
This boolean flag controls whether the interactive area of the SmartKeyHolder
(as determined by the raycast) should be visually represented in the Unity Editor’s Scene view. If set to true
, a visual debugging aid will show the reach of the raycast from the SmartKeyHolder
.
This is used in filtering the kinds of objects the SmartKeyHolder's
raycast can interact with. Only objects on layers defined by layerMask
can be interacted with, offering useful control over what kinds of objects the SmartKeyHolder
can register.
This is the maximum distance from the SmartKeyHolder
within which a SmartDoor
can be interacted with. If a SmartDoor
is outside of this distance, it won’t be registered by the SmartKeyHolder
.
This value is relevant when openDoorOnReach
is set to true
. It represents the minimum amount of time the player needs to be within the SmartKeyHolder's
maximum reach distance for a door to trigger and open.
If this is set to true
, it will cause doors to automatically open when a player character moves within the maximumReachDistance
of the SmartKeyHolder
.
This defines an offset for the starting position of the raycast. It can be useful for fine-tuning the exact area where interaction is triggered, depending on the positioning of your SmartKeyHolder
GameObject.