Core Interaction System Documentation
Introduction
This document provides a comprehensive guide to the CoreInteractionSystem, a plugin designed to enable developers to create dynamic and customizable interactions between actors in Unreal Engine. It focuses on simplicity, leveraging Blueprints for quick setup, while still offering flexibility for complex interactions. Below is an outline of the system's components, how to integrate them, and examples of usage.
- Core Components
- Trigger Component
- Receiver Component
- Trigger Actors
- Box Trigger
- Hit Trigger
- Rhythm Trigger
- Group Trigger
- Receiving Actors
- CameraSpawner
- Cannon
- Gate
- Pistol
- ShowingText
- SimpleAudioPlayer
- Spikes
- PhysicsObject
- Helper Components
- HomingComponent
- ShakingComponent
- ToggleVisibilityComponent
Core Components
The Core Components form the basis of the Interaction System. These components—TriggerComponent and ReceiverComponent—allow developers to create interactions between different actors with minimal effort, directly within Unreal Engine's Blueprint system.
- Trigger Component: Initiates interactions between actors.
- Receiver Component: Receives actions and executes them based on triggers.
Trigger Component
The Trigger Component is used to trigger interactions with actors that have a Receiver Component attached. It allows you to define which actors will be triggered and what actions will occur. You can implement your own interaction logic by calling the ActivateInteractions function. Additionally, the plugin provides predefined actors like BoxTrigger and HitTrigger, which already use the Trigger Component. You can find these examples in Content/Levels/ExampleMap to quickly set up interactions in your project.
Setup Instructions
- Place the ISTriggerComponent in the desired Blueprint.
- Call the ActivateInteraction Blueprint node during the desired event or situation to trigger the interaction.
- In the level editor, use the properties panel ("details" or "picker" window) to configure the
InteractionTargets. Choose the actor you want to be triggered, such as a door, and assign the appropriate action (e.g.,Action1for opening the door). - If you select
APlayerStartas the target, it will automatically reference the current player, making it easier to create player-based triggers.
Key Properties
Below are the key properties you can configure for the Trigger Component:
- InteractionTargets: A list of actors that the Trigger Component will interact with. Each target includes both the actor to trigger and the action to execute. You can assign actions like
Action1(e.g., Open Door) orAction2(e.g., Close Door) to specific actors. - bInfiniteTriggerCount: If true, the trigger can be activated an unlimited number of times.
- DisableTriggerAfterXHits: The number of times the trigger can be activated before becoming inactive (used when
bInfiniteTriggerCountis false). - NumberOfTriggeredInteractions: Tracks how many times the trigger has been activated (useful for debugging).
Receiver Component
The Receiver Component handles the incoming actions from the Trigger Component. When an action is triggered, the Receiver Component processes it and executes the corresponding behavior. You can customize what happens for each action by implementing the appropriate Blueprint logic.
The Receiver Component supports multiple actions (e.g., Action1, Action2, Action3), allowing you to define different behaviors for the same actor based on which action is triggered.
Trigger Actors
The Interaction System includes several predefined Trigger Actors that make it easy to set up common interaction scenarios. These actors already have the Trigger Component configured and are ready to use.
Box Trigger
The Box Trigger activates interactions when an actor enters or exits a defined box volume. This is useful for proximity-based triggers, such as opening doors when a player approaches.
Hit Trigger
The Hit Trigger activates interactions when the actor is hit by another actor, such as a projectile. This is useful for creating destructible objects or targets that respond to impacts.
Rhythm Trigger
The Rhythm Trigger activates interactions based on a timed rhythm or pattern. This can be used for creating musical or timing-based gameplay mechanics.
Group Trigger
The Group Trigger allows you to activate multiple interactions at once, making it easy to coordinate complex sequences of events.
Receiving Actors
The Interaction System includes several predefined Receiving Actors that demonstrate how to use the Receiver Component. These actors are fully functional examples that you can use in your projects.
CameraSpawner
The CameraSpawner spawns and manages camera actors for cinematic sequences or gameplay.
- Action1 - Spawns the camera.
- Action2 - Removes the camera.
Cannon
The Cannon fires projectiles when triggered. It includes visual and audio feedback via the ShakingComponent (recoil), Niagara effect, and sound.
- Action1 - Fires a projectile.
Gate
The Gate opens and closes based on player interaction. It uses physics constraints to manage movement.
- Action1 - Toggles between opening and closing.
- Action2 - Opens the gate.
- Action3 - Closes the gate.
Pistol
The Pistol is a gun that can be acquired in the example demo, using the ToggleVisibilityComponent to control its visibility.
- Action1 - Shows the pistol.
- Action2 - Hides the pistol.
ShowingText
The ShowingText actor is for displaying messages in the demo.
- Action1 - Shows the text.
- Action2 - Hides the text.
SimpleAudioPlayer
The SimpleAudioPlayer plays sound and controls fading out.
- Action1 - Plays the audio.
- Action2 - Fades out the audio.
Spikes
The Spikes actor is a trap using physics constraints to activate or deactivate the spikes.
- Action1 - Toggles the spikes.
- Action2 - Activates the spikes.
- Action3 - Deactivates the spikes.
Physics Object
The Physics Object is a ball with physics enabled. It demonstrates how physics can be integrated into the Interaction System.
- Action1 - Enables physics.
- Action2 - Disables physics.
These actors showcase the flexibility of the Interaction System. You can develop and customize your own receiving actors with any behavior you define, making it versatile for various gameplay scenarios.
Helper Components
The Interaction System includes several Helper Components that developers can use to quickly add additional behavior to their actors. These components are designed to simplify the creation of gameplay mechanics, making it easier to add complex behaviors to your actors.
HomingComponent
The HomingComponent allows the owner actor to home in on a target. It is useful for creating projectiles or AI that follow a player or another actor. The component provides options to pick a target directly in the level editor or use a special boolean to automatically assign the player as the target. It also has properties to control oscillation for smoother movement.
SwitchState(EISHomingState::Off)- Turns off the homing behavior.SwitchState(EISHomingState::On)- Turns on the homing behavior.
ShakingComponent
The ShakingComponent adjusts the parent actor's transform over time, allowing you to create shaking effects defined by curves. This is useful for single-use effects like gun recoil or looping effects like camera shakes or hovering animations. It can also simulate larger effects such as earthquakes or explosions.
SwitchState(EISShakingComponentState::Off)- Turns off the shaking effect.SwitchState(EISShakingComponentState::Once)- Activates a one-time shaking effect.SwitchState(EISShakingComponentState::Looping)- Activates the shaking effect in a loop.
When bApplyRelativeOffset is set to true, the curves are applied as offsets to the actor's transform, adding dynamic shaking effects. This is perfect for things like gun recoil, target hit effects, camera shakes during impacts, or even simulating an earthquake after an explosion.
Developer's Note: The ShakingComponent can add a lot of "juice" to your game when configured with the right curves, making interactions more dynamic and immersive. I'm considering expanding it in the future to include lattice deformations, providing even more control over the visual effects.
ToggleVisibilityComponent
The ToggleVisibilityComponent allows actors to toggle their visibility on and off. This is a simple yet effective way to show or hide objects in your scene, such as making a pistol visible when picked up or hiding it when holstered.