A small plugin for implementing a flexible keyring system.
The plugin can be used in both C++ and Blueprint projects.
- Download the latest package file;
- Install the plugin either in your project or for all projects in engine:
- Unzip the package into Plugins folder of your project, e.g.
D:\UnrealProjects\MyProject\Plugins
; - Unzip the package to the Plugins folder in engine folder, e.g.
C:\Program Files\Epic Games\UE_5.0\Engine\Plugins
;
- Unzip the package into Plugins folder of your project, e.g.
- Restart the project;
In this case the plugin can be used for any blueprint project.
- Create the Plugins folder in the project directory;
- Create the TrickyAnimationComponents folder in the Plugins folder;
- Download the plugin source code into that folder;
- Rebuild the project;
The plugin contains:
- KeyType object;
- KeyringComponent;
- KeyringLibrary;
- LockComponent;
The object from which key classes must be inherited.
DestroyOnUse
- toggles if the key must be removed from the keyring after calling theUseKey
function;KeyData
- a struct which contains some information for the HUD;Name
- the name of the key;Color
- color of the key;
A component which manages keys the player got.
AddKey
- adds a key of a given class to the keyring. Returns true if the key was added;RemoveKey
- removes a key of a give class from the keyring regardless the value of DestroyOnUse. Returns true if the key was removed;RemoveAllKeys
- removes all keys in the keyring. Returns true if all keys were removed;UseKey
- calls theOnKeyUsed
delegate and removes a key of a given class if DestroyOnUse == true. Returns true if the key was successfully used;KeyringIsEmpty
- checks if the keyring array is empty;HasKey
- checks if the keyring has a key of a given class;GetKeyDataByIndex
- returns key data structure by index of the key in the array;GetKeyDataByClass
- returns key data structure by given class of the key;
OnKeyAdded
- called when the key was successfully added to the keyring;OnKeyRemoved
- called when the key was successfully removed from the keyring;OnKeyUsed
- called when the key was successfully used;
A function library with useful functions to work with KeyringComponent.
GetKeyringComponent
- returns KeyringComponent if the given actor has one;ActorHasKey
- checks if the given actor has key;AddKey
- adds key to KeyringComponent of the given actor;RemoveKey
- removes key from KeyringComponent of the given actor;UseKey
- force the given actor to use the given key class;GetKeyObject
- returns a key object from KeyringComponent of the given actor;GetKeyData
- returns key data from KeyringComponent of the given actor;IsKeyDestroyable
- checks if the given key class is destroyable;RemoveAllKeys
- removes all keys form KeyringComponent of the given actor;
Controls locking/unlocking by a given key.
bLockedOnStart
- toggles if the component is locked on begin play;RequiredKey
- the key type required to lock/unlock the component;bLockingRequiresKey
- toggles if the key is required to lock the component;
Lock
- locks the component;Unlock
- unlocks the component;CanUseLock
- checks if the component can be locked/unlocked by a given actor;GetIsLocked
- returns if the component is locked or not;
OnLocked
- called when the component was locked;OnUnlocked
- called when the component was unlocked;OnCantLocked
- called when the component cant be locked;OnCantUnlock
- called when the component cant be unlocked;
- Add KeyRingComponent to your character;
- Create key classes you need inherited from KeyType object;
- Add and adjust LockComponent to actors which must be locked;
- Implement lock/unlock logic in the actors with LockComponent;
- Give player keys using pickups or other in-game methods;