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

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.

Split Screen for adding components

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

  1. Place the ISTriggerComponent in the desired Blueprint.
  2. Call the ActivateInteraction Blueprint node during the desired event or situation to trigger the interaction.
  3. 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., Action1 for opening the door).
  4. If you select APlayerStart as the target, it will automatically reference the current player, making it easier to create player-based triggers.
ActivateInteractions

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) or Action2 (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 bInfiniteTriggerCount is false).
  • NumberOfTriggeredInteractions: Tracks how many times the trigger has been activated (useful for debugging).

Understanding InteractionTargets

The InteractionTargets property allows you to define both the actor to interact with and the action that should be executed. For example, you can specify that Action1 (e.g., Open Door) is assigned to one actor, while Action2 (e.g., Close Door) is assigned to another. This flexible setup enables you to control multiple actors with different actions through a single trigger. Additionally, when selecting APlayerStart as a target, the system will automatically reference the current player, simplifying player-based interactions.

PickingReference
Hitting target opens gate and shakes player.

Receiver Component

The Receiver Component is the counterpart to the Trigger Component. It allows actors to respond to interactions initiated by the Trigger Component. For example, you can add a Receiver Component to a door, and when a trigger is activated, the door opens. The Receiver Component supports up to 10 action slots, allowing you to define multiple responses in your Blueprint (e.g., Action1 = Open Door, Action2 = Close Door).

Additionally, there are preconfigured actors that come with a Receiver Component already set up, making it easy to integrate them into your project. Trigger actors can also have their own Receiver Components, enabling chain reactions where one triggered actor can further trigger interactions on another actor.

Setup Instructions

Follow these steps to set up the Receiver Component in your project:

  1. Open the Blueprint of the actor you want to respond to interactions.
  2. Add the ISReceiverComponent to the Blueprint.
  3. Select the action event you want the actor to respond to (e.g., OnActivateAction1).
  4. Define the logic for what should happen when the action is triggered (e.g., opening a door).
ActivateInteractions

Key Properties

Below are the key properties you can configure for the Receiver Component:

  • OnActivateAction1: Event triggered when Action1 is activated by the Trigger Component.
  • OnActivateAction2: Event triggered when Action2 is activated by the Trigger Component.
  • ...up to OnActivateAction10.

Trigger Actors

Predefined Trigger Actors in the Interaction System come with their own Trigger Component configurations. These actors are ready to be used out of the box for typical interaction cases. Below is a list of the available predefined Trigger Actors:

  • Box Trigger: Used for proximity-based interactions (e.g., opening doors when a player enters an area).
  • Hit Trigger: Activates interactions upon physical collision (e.g., hitting a target with a projectile).
  • Rhythm Trigger: Triggers interactions based on predefined rhythmic patterns (e.g., synchronizing interactions with beats).
  • Group Trigger: Allows for multiple interactions to be triggered simultaneously or sequentially (e.g., opening multiple doors at once).

Box Trigger

The Box Trigger is a predefined actor designed for proximity-based interactions. It uses a collision box to detect when an actor (like a player) enters or leaves the area. This trigger can activate interactions when overlapping begins and ends, allowing for actions like automatic door opening and closing.

Make sure to configure the collision settings inside BP_BoxTrigger to fit your needs. By default, the collision is set for Pawns, but you can adjust it based on your specific requirements.

Setup Instructions:

  1. Add the BP_BoxTrigger actor to your level. You can find it in the Content/Blueprints/Triggers folder.
  2. Define the InteractionTargets in the BeginOverlapInteractions and EndOverlapInteractions trigger components.
BoxTrigger Setup
When player walks into BoxTrigger, gun appears.

Hit Trigger

The Hit Trigger activates interactions based on physical collisions. This trigger is ideal for interactions where an actor needs to respond to being hit, such as destructible objects or targets.

Setup Instructions:

  1. Add the BP_HitTrigger actor to your level.
  2. Set HitTriggerMesh.
  3. Configure the HitInteractions trigger component to define which actors will receive the interaction.
  4. Optionally, add sound effects using the HitTriggerSound property.

Rhythm Trigger

The Rhythm Trigger is designed for interactions synced with rhythmic patterns, ideal for time-based or beat-based mechanics. It behaves like a "beat machine," allowing developers to record rhythm patterns and trigger interactions accordingly. This is particularly useful for timing complex sequences like moving walls or shooting cannons in platformer-style games.

Developer's Note: I apologize for any overengineering in this actor. Its main purpose is to help time different interactions. A video tutorial will be available to explain the setup in more detail. Watch the tutorial.

Key Features:

  • Supports recording key-based interactions for rhythmic patterns.
  • Allows for dynamic playback and recording of interaction sequences.
  • Customizable rhythm configuration, with options for looping or one-time interactions.

Setup Instructions - Manual:

  1. Add the BP_RhythmTrigger actor to your level.
  2. You can manually fill the rhythm data by editing the DataAsset file directly. This option gives full control over the interaction timing and behavior.

Setup Instructions - Key-Based Recording (without keyboard possession):

  1. Add the BP_RhythmTrigger actor to your level.
  2. Set the bUseKeyRecording property to false.
  3. Define the interactions for keys (e.g., Key1, Key2) in the KeyInteractionTargetsMap.
  4. Then press Simulate, hit the Record button, and trigger interactions by clicking Key1, Key2, Key3, etc., using the mouse.
  5. After recording, you can use the Set Loop Duration button to set the loop time (the duration for repeating the sequence).

Setup Instructions - Key-Based Recording (with keyboard possession):

  1. Add the BP_RhythmTrigger actor to your level.
  2. Set the bUseKeyRecording property to true.
  3. Then press Simulate
  4. Press the Record button, which will possess the player and assign keys 0–9 to your keyboard.
  5. Press keys to record interactions
  6. Hit Enter to set loop duration

Advanced Features:

  • Recording with Music: You can use the Set Loop Duration from Sound button to sync the interaction sequence with a music pattern, allowing you to time interactions to specific accents in the music. This feature is experimental and primarily intended for timing complex sequences with music-based rhythms.
  • Key Mapping: The KeytoFKeyMap property allows you to map specific keys on your keyboard to trigger the corresponding interactions during recording. If you need to customize which keys trigger certain actions, you can modify this mapping as needed.

If you want to clear your recording and start over, you can either manually clear the DataAsset file or press the Clear button. This allows you to reset the recording environment before starting a new sequence.

Group Trigger

The Group Trigger is an organizing actor that combines both a Trigger Component and a Receiver Component, allowing you to stack multiple interactions into one. It is designed to trigger a group of actors either simultaneously.

Receiving Actors

These actors demonstrate how to integrate various interactions into your projects using the Interaction System. Each actor responds to specific actions, showcasing how flexible the system is for custom development.

CameraSpawner

The CameraSpawner spawns actors relative to the player's camera. It's ideal for spawning flying objects or enemies that attack the player.

  • Action1 - Triggers spawning based on defined Offset and BoxExtent.

Cannon

The Cannon fires projectiles and 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.