Skip to content

JDSherbert/Unreal-Engine-Interaction-System

Repository files navigation

image

Unreal Engine Interaction System

Stars Badge Forks Badge Watchers Badge Issues Badge


Unreal Engine Template License




Overview

This interaction system provides a simple and modular solution for handling interactions between an interactor (InteractorComponent) and interactable actors (InteractableComponent) in Unreal Engine. The system facilitates communication between these components through a defined interface, allowing you to easily implement and customize interactions within your projects! Events are also exposed, so you can have unique per object outcomes if you like. It works by raycasting to the hitbox of the actor, and generally works best in a 1st person setup.

Components

Interactor

The Interactor component is responsible for initiating interactions with interactable objects. It is typically attached to the player character, or any other actor that needs interaction capabilities.

Usage:
  • Attach to Character: Add the Interactor component to your player character or desired actor.
  • Input Action: Configure an input action for interaction (e.g., "Interact"). Bind this action in your player controller or wherever input handling is managed.

Interactable

The Interactable component represents objects in the world that can be interacted with. It responds to interaction requests from Interactors.

Usage:
  • Attach to Actors: Add the Interactable component to any actor you want to make interactable.
  • Implement Interface: Make sure the actor implements the IInteractableInterface interface. This interface defines the methods needed for interaction.
  • Interaction Interface (IInteractableInterface)
  • The interface defines the communication contract between Interactors and Interactables. It includes methods like OnInteract that need to be implemented by Interactable actors.

Implementation Step

Attach Components

Attach the Interactor component to your player character or actor that will perform interactions. Attach the Interactable component to any actor you want to make interactable.

Input Action

As we are using the enhanced input system, define an input action for interaction (e.g., "Interact"). Assign the InputAction in the component via the blueprint inspector, or you can use constructor helpers in the code.

UUserWidgets

Create UUserWidgets (UI) for any interactive feedback you want to provide to the player during interactions. These widgets are triggered by the Interactable actors during interaction events. You'll need to make an "E To Interact" and "Cannot Interact" widget. Assign these in the blueprint too.

Implement Interaction

As we are using events, you can add your own logic in blueprint (or code!) as required.


About

Simple implementation of an Interaction System for Unreal Engine. Utilises two components that communicate with each other through an interface.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages