🎮

Creating Hold Interactions in Unreal Engine 5

Aug 28, 2024

Unreal Engine 5 Tutorial: Hold Interaction with a Key

Introduction

  • Welcome to a new Unreal Engine 5 tutorial.
  • Focus: Creating a hold interaction using the enhanced input system in UE 5.1.
  • Check the description for links to Unreal Engine courses.

Step 1: Create Input Key

  • Navigate to the third-person folder.
  • Locate the Input folder and find Actions.
  • Right-click -> Input -> Create New Input Action.
    • Suggested prefix: EA_ (e.g., EA_Interact).
  • Double-click to edit, but don't assign a key yet.

Step 2: Configure Input Action

  • Ensure Consume Input is enabled to allow input to be registered.
  • Set Value Type to Boolean (on/off).
  • Add a trigger:
    • Use the Hold trigger type.
    • Adjust the hold time to determine how long the key must be held.
  • Save changes.

Step 3: Assign Key

  • Go to the collection and add a new mapping for the interact key.
  • Press the desired key to assign it (e.g., T).
  • Optionally, override and add more triggers/modifiers.

Step 4: Blueprint Setup

  • Open the character blueprint (e.g., third person).
  • Add input mapping for EA_Interact.
    • Use the trigger event for actions based on key presses.
    • Print a string after a one-second hold to test functionality.
  • Address constant spamming issue:
    • Use the One Shot option to only trigger once upon holding.

Step 5: Create User Interface

  • Create a UI widget called WB_Interacting.
  • Add a canvas and center a text element on the screen.
    • Set text to "Interacting..."
    • Adjust position and size as needed.
  • In the third-person blueprint:
    • On startup, create and add the widget to the viewport.
    • Promote to variable for future reference.
    • Use validity check to prevent errors when deleting the widget.

Step 6: Test Interaction

  • On holding the interaction key:
    • The UI appears.
    • Upon release, perform an action (e.g., print "Hello" or make the character jump).

Conclusion

  • The tutorial covers how to create a hold interaction using Unreal Engine 5.
  • Encouragement to like, subscribe, and check out more tutorials.
  • Invitation to join Discord and follow on social media.