Tricky Gameplay Objects is a plugin for Unreal Engine 5 that provides reusable components and interfaces for managing common gameplay mechanics such as doors, chests, locks, buttons, and more. These systems are designed to improve the workflow for developing interactive gameplay objects, making it easier to handle complex state transitions, interactions, and key/lock systems.
-
State Management Components:
DoorStateController
: Controls door states such as opened, closed, locked, disabled.ChestStateController
: Controls chest states such as opened, closed, locked, disabled.LockStateController
: Controls lock states such as locked, unlocked, disabled.ButtonStateController
: Controls button states such as pressed, released, disabled.GameplayObjectStateController
: Controls generic gameplay objects states such as active, inactive, disabled.
-
Blueprint Integration:
- All components and interfaces are fully exposed to Blueprints.
- Seamless integration allows for rapid prototyping and easier customization.
-
Simple LockKey System:
KeyringComponent
: A reusable component for managing acquired lock keys (adding, removing, using keys).LockKeyType
: A class representing key types used to interact with locks, chests, doors, and other objects.
- Copy the plugin folder to your project's
Plugins
directory. - Open your Unreal Engine project.
- Enable the
TrickyGameplayObjects
plugin in the Plugins menu. - Restart the editor.
All components have a number of properties, functions and delegates which can be used to implement them.
-
InitialState
- Defines the initial state of the door during component initialization.
- Cannot be set to
Transition
.
-
CurrentState
- Tracks the door's current operational state.
-
TargetState
- Represents the state the door is transitioning to.
-
LastState
- Holds the previous state of the door before the last state transition.
-
OpenDoor(bool bTransitImmediately)
Attempts to open the door.bTransitImmediately
: Determines if the door should switch to the open state immediately.- Returns
true
if successful.
-
CloseDoor(bool bTransitImmediately)
Attempts to close the door.bTransitImmediately
: Determines if the door should switch to the closed state immediately.- Returns
true
if successful.
-
LockDoor(bool bTransitImmediately)
Attempts to lock the door.- The door must be in the
Closed
state to lock. bTransitImmediately
: Determines if the door should switch to the locked state immediately.- Returns
true
if successful.
- The door must be in the
-
UnlockDoor(bool bTransitImmediately)
Attempts to unlock the door.- The door must be in the
Locked
state to unlock. bTransitImmediately
: Determines if the door should switch to the unlocked state immediately.- Returns
true
if successful.
- The door must be in the
-
DisableDoor(bool bTransitImmediately)
Disables the door, putting it in a non-interactable state.bTransitImmediately
: Determines if the door should immediately transition to the disabled state.- Returns
true
if successful.
-
EnableDoor(bool bTransitImmediately)
Re-enables a disabled door, restoring it to its last state (LastState
).bTransitImmediately
: Determines if the door should immediately transition to its restored state.- Returns
true
if successful.
-
ForceDoorState(EDoorState NewState, bool bTransitImmediately)
Forces the door into a specific state, skipping normal state checks.NewState
: The desired state (Opened
,Closed
, etc.).bTransitImmediately
: Determines if the transition should occur immediately.- Returns
true
if successful.
-
FinishDoorStateTransition()
Completes a state transition if the door is currently in theTransition
state.- Returns
true
if the transition is completed.
- Returns
-
ReverseDoorStateTransition()
Reverses a state transition, swappingTargetState
andLastState
.- Returns
true
if successful.
- Returns
-
OnDoorStateChanged
Triggered when theCurrentState
changed.- Parameters:
Component
,NewState
,bChangedImmediately
.
- Parameters:
-
OnDoorStateTransitionStarted
Triggered when the door enters theTransition
state.- Parameters:
Component
,TargetState
.
- Parameters:
-
OnDoorStateTransitionFinished
Triggered when the door exits theTransition
state and reaches itsTargetState
.- Parameters:
Component
,NewState
.
- Parameters:
-
OnDoorStateTransitionReversed
Triggered when a state transition is reversed (swappingTargetState
andLastState
).- Parameters:
Component
,NewTargetState
.
- Parameters:
-
InitialState
- Defines the initial state of the chest during component initialization.
- Cannot be set to
Transition
.
-
CurrentState
- Tracks the chest's current operational state.
-
TargetState
- Represents the state the chest is transitioning to.
-
LastState
- Holds the previous state of the chest before the last state transition.
-
OpenChest(bool bTransitImmediately)
Attempts to open the chest.bTransitImmediately
: Determines if the chest should switch to the open state immediately.- Returns
true
if successful.
-
CloseChest(bool bTransitImmediately)
Attempts to close the chest.bTransitImmediately
: Determines if the chest should switch to the closed state immediately.- Returns
true
if successful.
-
LockChest(bool bTransitImmediately)
Attempts to lock the chest.- The chest must be in the
Closed
state to lock. bTransitImmediately
: Determines if the chest should switch to the locked state immediately.- Returns
true
if successful.
- The chest must be in the
-
UnlockChest(bool bTransitImmediately)
Attempts to unlock the chest.- The chest must be in the
Locked
state to unlock. bTransitImmediately
: Determines if the chest should switch to the unlocked state immediately.- Returns
true
if successful.
- The chest must be in the
-
DisableChest(bool bTransitImmediately)
Disables the chest, putting it in a non-interactable state.bTransitImmediately
: Determines if the chest should immediately transition to the disabled state.- Returns
true
if successful.
-
EnableChest(bool bTransitImmediately)
Re-enables a disabled chest, restoring it to its last state (LastState
).bTransitImmediately
: Determines if the chest should immediately transition to its restored state.- Returns
true
if successful.
-
ForceChestState(EChestState NewState, bool bTransitImmediately)
Forces the chest into a specific state, skipping normal state checks.NewState
: The desired state (Opened
,Closed
, etc.).bTransitImmediately
: Determines if the transition should occur immediately.- Returns
true
if successful.
-
FinishChestStateTransition()
Completes a state transition if the chest is currently in theTransition
state.- Returns
true
if the transition is completed.
- Returns
-
ReverseChestStateTransition()
Reverses a state transition, swappingTargetState
andLastState
.- Returns
true
if successful.
- Returns
-
OnChestStateChanged
Triggered when theCurrentState
changed.- Parameters:
Component
,NewState
,bChangedImmediately
.
- Parameters:
-
OnChestStateTransitionStarted
Triggered when the chest enters theTransition
state.- Parameters:
Component
,TargetState
.
- Parameters:
-
OnChestStateTransitionFinished
Triggered when the chest exits theTransition
state and reaches itsTargetState
.- Parameters:
Component
,NewState
.
- Parameters:
-
OnChestStateTransitionReversed
Triggered when a state transition is reversed (swappingTargetState
andLastState
).- Parameters:
Component
,NewTargetState
.
- Parameters:
-
InitialState
- Defines the initial state of the lock during component initialization.
- Cannot be set to
Transition
.
-
CurrentState
- Tracks the lock's current operational state.
-
TargetState
- Represents the state the lock is transitioning to.
-
LastState
- Holds the previous state of the lock before the last state transition.
-
Lock(bool bTransitImmediately)
Attempts to lock the lock.- The lock must be in the
Unlocked
state to lock. bTransitImmediately
: Determines if the lock should switch to the locked state immediately.- Returns
true
if successful.
- The lock must be in the
-
Unlock(bool bTransitImmediately)
Attempts to unlock the lock.- The lock must be in the
Locked
state to unlock. bTransitImmediately
: Determines if the lock should switch to the unlocked state immediately.- Returns
true
if successful.
- The lock must be in the
-
DisableLock(bool bTransitImmediately)
Disables the lock, putting it in a non-interactable state.bTransitImmediately
: Determines if the lock should immediately transition to the disabled state.- Returns
true
if successful.
-
EnableLock(bool bTransitImmediately)
Re-enables a disabled lock, restoring it to its last state (LastState
).bTransitImmediately
: Determines if the lock should immediately transition to its restored state.- Returns
true
if successful.
-
ForceLockState(ELockState NewState, bool bTransitImmediately)
Forces the lock into a specific state, skipping normal state checks.NewState
: The desired state (Locked
,Unlocked
, etc.).bTransitImmediately
: Determines if the transition should occur immediately.- Returns
true
if successful.
-
FinishLockStateTransition()
Completes a state transition if the lock is currently in theTransition
state.- Returns
true
if the transition is completed.
- Returns
-
ReverseLockStateTransition()
Reverses a state transition, swappingTargetState
andLastState
.- Returns
true
if successful.
- Returns
-
OnLockStateChanged
Triggered when theCurrentState
changed.- Parameters:
Component
,NewState
,bChangedImmediately
.
- Parameters:
-
OnLockStateTransitionStarted
Triggered when the lock enters theTransition
state.- Parameters:
Component
,TargetState
.
- Parameters:
-
OnLockStateTransitionFinished
Triggered when the lock exits theTransition
state and reaches itsTargetState
.- Parameters:
Component
,NewState
.
- Parameters:
-
OnLockStateTransitionReversed
Triggered when a state transition is reversed (swappingTargetState
andLastState
).- Parameters:
Component
,NewTargetState
.
- Parameters:
-
InitialState
- Defines the initial state of the button during component initialization.
- Cannot be set to
Transition
.
-
CurrentState
- Tracks the button's current operational state.
-
TargetState
- Represents the state the button is transitioning to.
-
LastState
- Holds the previous state of the button before the last state transition.
-
PressButton(bool bTransitImmediately)
Attempts to press the button.- The button must be in the
Released
state to press. bTransitImmediately
: Determines if the button should switch to the pressed state immediately.- Returns
true
if successful.
- The button must be in the
-
ReleaseButton(bool bTransitImmediately)
Attempts to release the button.- The button must be in the
Pressed
state to release. bTransitImmediately
: Determines if the button should switch to the released state immediately.- Returns
true
if successful.
- The button must be in the
-
DisableButton(bool bTransitImmediately)
Disables the button, putting it in a non-interactable state.bTransitImmediately
: Determines if the button should immediately transition to the disabled state.- Returns
true
if successful.
-
EnableButton(bool bTransitImmediately)
Re-enables a disabled button, restoring it to its last state (LastState
).bTransitImmediately
: Determines if the button should immediately transition to its restored state.- Returns
true
if successful.
-
ForceButtonState(EButtonState NewState, bool bTransitImmediately)
Forces the button into a specific state, skipping normal state checks.NewState
: The desired state (Pressed
,Released
, etc.).bTransitImmediately
: Determines if the transition should occur immediately.- Returns
true
if successful.
-
FinishButtonStateTransition()
Completes a state transition if the button is currently in theTransition
state.- Returns
true
if the transition is completed.
- Returns
-
ReverseButtonStateTransition()
Reverses a state transition, swappingTargetState
andLastState
.- Returns
true
if successful.
- Returns
-
OnButtonStateChanged
Triggered when theCurrentState
changed.- Parameters:
Component
,NewState
,bChangedImmediately
.
- Parameters:
-
OnButtonStateTransitionStarted
Triggered when the button enters theTransition
state.- Parameters:
Component
,TargetState
.
- Parameters:
-
OnButtonStateTransitionFinished
Triggered when the button exits theTransition
state and reaches itsTargetState
.- Parameters:
Component
,NewState
.
- Parameters:
-
OnButtonStateTransitionReversed
Triggered when a state transition is reversed (swappingTargetState
andLastState
).- Parameters:
Component
,NewTargetState
.
- Parameters:
-
InitialState
- Defines the initial state of the gameplay object during component initialization.
- Cannot be set to
Transition
.
-
CurrentState
- Tracks the gameplay object's current operational state.
-
TargetState
- Represents the state the gameplay object is transitioning to.
-
LastState
- Holds the previous state of the gameplay object before the last state transition.
-
ActivateGameplayObject(bool bTransitImmediately)
Attempts to activate the gameplay object.- The gameplay object must be in the
Inactive
state to press. bTransitImmediately
: Determines if the gameplay object should switch to the active immediately.- Returns
true
if successful.
- The gameplay object must be in the
-
DeactivateGameplayObject(bool bTransitImmediately)
Attempts to deactivate the gameplay object.- The gameplay object must be in the
Active
state to release. bTransitImmediately
: Determines if the gameplay object should switch to the inactive state immediately.- Returns
true
if successful.
- The gameplay object must be in the
-
DisableGameplayObject(bool bTransitImmediately)
Disables the gameplay object, putting it in a non-interactable state.bTransitImmediately
: Determines if the gameplay object should immediately transition to the disabled state.- Returns
true
if successful.
-
EnableGameplayObject(bool bTransitImmediately)
Re-enables a disabled gameplay object, restoring it to its last state (LastState
).bTransitImmediately
: Determines if the gameplay object should immediately transition to its restored state.- Returns
true
if successful.
-
ForceGameplayObjectState(EGameplayObjectState NewState, bool bTransitImmediately)
Forces the gameplay object into a specific state, skipping normal state checks.NewState
: The desired state (Active
,Inactive
, etc.).bTransitImmediately
: Determines if the transition should occur immediately.- Returns
true
if successful.
-
FinishGameplayObjectStateTransition()
Completes a state transition if the gameplay object is currently in theTransition
state.- Returns
true
if the transition is completed.
- Returns
-
ReverseGameplayObjectStateTransition()
Reverses a state transition, swappingTargetState
andLastState
.- Returns
true
if successful.
- Returns
-
OnGameplayObjectStateChanged
Triggered when theCurrentState
changed.- Parameters:
Component
,NewState
,bChangedImmediately
.
- Parameters:
-
OnGameplayObjectStateTransitionStarted
Triggered when the gameplay object enters theTransition
state.- Parameters:
Component
,TargetState
.
- Parameters:
-
OnGameplayObjectStateTransitionFinished
Triggered when the gameplay object exits theTransition
state and reaches itsTargetState
.- Parameters:
Component
,NewState
.
- Parameters:
-
OnGameplayObjectStateTransitionReversed
Triggered when a state transition is reversed (swappingTargetState
andLastState
).- Parameters:
Component
,NewTargetState
.
- Parameters:
AcquiredKeys
- Stores an array of lock key types (
TSubclassOf<ULockKeyType>
) that have been acquired by the component. - This property is maintained internally and is not directly exposed to modify. Use provided functions to manage the keyring.
- Stores an array of lock key types (
-
GetAcquiredKeys
- Retrieves the current list of acquired lock keys.
- Returns
AcquiredLockKeys
: An array of acquired lock key types.
-
AddLockKey
- Adds a new lock key to the component, ensuring uniqueness.
LockKey
: The lock key type to add.- Returns
true
if the key was added successfully,false
otherwise.
-
RemoveLockKey
- Removes a specific lock key type from the component.
LockKey
: The lock key type to remove.- Returns
true
if the key was removed successfully,false
otherwise.
-
RemoveAllLockKeys
- Clears all acquired lock keys from the component.
- Returns
true
if all keys were successfully removed,false
otherwise.
-
UseLockKey
- Attempts to use a specific lock key from the component.
LockKey
: The lock key type to use.- Returns
true
if the key was successfully used,false
otherwise.
-
HasLockKey
- Checks if the specified lock key type exists in the component.
LockKey
: The lock key type to check.- Returns
true
if the key is present,false
otherwise.
-
OnLockKeyAdded
- Triggered after a new lock key is successfully added to the component.
- Parameters:
Component
,LockKey
.
-
OnLockKeyRemoved
- Triggered when a lock key is successfully removed from the component.
- Parameters:
Component
,LockKey
.
-
OnAllLockKeysRemoved
- Triggered when all lock keys are removed from the component.
- Parameters:
Component
.
-
OnLockKeyUsed
- Triggered when a lock key is successfully used by the component.
- Parameters:
Component
,LockKey
.
PickupBase class contains the core logic for pickups.
bDestroyAfterActivation
- Determines if the actor will be destroyed after successful activation.
- Defaults to
true
.
-
ActivatePickup
Attempts to activate the pickup with the specified activator.Activator
: The actor attempting to activate the pickup.- Returns
true
if the pickup was successfully activated.
-
CanBeActivated
Determines if the pickup can be activated by the specified actor.Activator
: The actor attempting to activate the pickup.- Returns
true
if the pickup can be activated. - Can be overridden in Blueprint classes.
-
HandleActivationSuccess
Handles the logic to be executed when the pickup is successfully activated.Activator
: The actor attempting to activate the pickup.- Can be overridden in Blueprint classes.
-
HandleActivationFailure
Handles the logic to be executed when the activation of the pickup fails.Activator
: The actor attempting to activate the pickup.- Can be overridden in Blueprint classes.
OnPickupActivated
Called when the pickup actor was successfully activated.- Parameters:
Pickup
,Activator
.
- Parameters:
Inherits from PickupBase and represents a pickup actor which activates its logic automatically on activation trigger overlap.