Skip to content

CusYaBasic/InteractionSystem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Unreal Engine 5 Interaction System:

This is an Interaction System for Unreal Engine 5; It handles player interaction with any interactable world object.

Pros:

  • Pretty much plug and play; All logic is ran from a single actor component InteractionComponent and a interface InteractionInterface
  • Uses interfaces; So no need to reparent any of your existing actors to a base interactable class
  • Easy to use; Straight-forward with no bloat
  • Blueprint accessable; No code required
  • Uses timers; Not tick
  • Clean and commented

Cons:

  • Not network replicated

Getting Started:

  1. First thing you need to do is add the Interaction component to your player character/pawn

image

  1. Once the component has been added; tweak the settings to your liking

image

  1. Add the InteractionInterface to any of the actors you wish to be seen as an Interactable

image

and thats it! You're now all set and can start using the interaction plugin!


Using the Plugin:

Using the plugin is very simple; all you need to do is call StartInteractionTrace() and it will start tracing for interactables (if you have bStartOnBeginPlay set as true you can skip this).

If we hit an Interactable then it will update the TargetActor variable in the component

image

Stopping the trace is just as easy; Just call StopInteractionTrace() and the trace will forget the TargetActor and stop.

image

We can interact with our TargetActor by calling the InteractWithTargetActor() function. This will simply check if the TargetActor is valid and has the InteractableInterface then interacts with it.

image

Delegates:

There are a few Delegates that you can bind too when certian things happen from within the interaction system.

image

OnTargetActorUpdated:

Fires when the trace hits a new actor and updates the TargetActor in the component

image

OnTargetActorForgotten:

Fires when the TargetActor has been forgetten or replaced

image


Interaction Interface:

The InteractionInterface is how we can detect Interactables without having to convert any actors to a child of a base interactable class. Just add this interface to any actor you want to be deemed as an Interactable and the component will do the rest!

Interface Functions:

The InteractionInterface has a few functions which you would need to override so you can select funtionality dependant on the actor it is overridden in.

image

Interact:

Interact() is what gets called on the Interactable when InteractWithTargetActor() is called. This is the bare minimum needed for the Interactable to work.

image

BecomeTarget:

Not as important; but there is also BecomeTarget(). Override this and you can add funtionality for when the Interactable becomes the TargetActor

image

ForgottenAsTarget:

Not as important; but there is also ForgottenAsTarget(). Override this and you can add funtionality for when the Interactable is no longer the TargetActor

image


Tutorial Video

Watch the video


License

This plugin is licensed under CC BY-NC 4.0.
You can use it for free in commercial and personal projects, but you cannot sell or distribute this plugin or any modified version of it.
See the full license: CC BY-NC 4.0


About

A plugin that handles player interaction with world objects for Unreal Engine 5

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published