Skip to content

Interact Trigger

Introduction

A trigger that can be used to interact with an object

Dependencies

The InteractTrigger relies on other components of this plugin to work:

  • Logger: Used to log useful information to help you debug any issues you might experience

API Reference

Properties

Property Description Type Default Value
bRequireCurrency Is this a paid item that should be bought using currency? bool false
CurrencyRequirements The currency requirements before the object can be interacted with TMap<FName, int>
InteractWidgetClass The class of the interact widget TSubclassOf<UInteractWidget>
BeforeText The text displayed before the input indicator FText
AfterText The text displayed after the input indicator FText

Functions

Name Description Params Return
CanInteract Check if the actor can interact with the object Actor (AActor*)
The actor trying to interact with the object
bool
A boolean value indicating if the actor can interact with the object
OnInteracted Called when the actor interacts with the object Actor (AActor*)
The actor that interacted with the object
ReceiveOnInteracted Called when the actor interacts with the object Actor (AActor*)
The actor that interacted with the object

Blueprint Usage

You can use the InteractTrigger using Blueprints by adding one of the following nodes:

  • Ultimate Starter Kit > Interact Trigger > Can Interact
  • Ultimate Starter Kit > Interact Trigger > On Interacted
  • Ultimate Starter Kit > Interact Trigger > OnInteracted

C++ Usage

Before you can use the plugin, you first need to enable the plugin in your Build.cs file:

PublicDependencyModuleNames.Add("USK");

The InteractTrigger can now be used in any of your C++ files:

#include "USK/Components/InteractTrigger.h"

void ATestActor::Test()
{
    // InteractTrigger is a pointer to the UInteractTrigger
    bool CanInteractValue = InteractTrigger->CanInteract(Actor);
    InteractTrigger->OnInteracted(Actor);
    InteractTrigger->ReceiveOnInteracted(Actor);
}