unfurl

Interaction

Press and hold interactions with aim, nearby targets, and server requests for Unreal Engine.

Press and hold interactions with aim, nearby targets, and server requests for Unreal Engine.

👀 Summary

NsInteraction lets an actor, usually the player, use other actors. A sensor gives the targets. The interaction component asks each target for its option, keeps the best one, and runs it on a press or at the end of a hold. A ready-made interactable actor covers the simple case with no code.

NsInteraction has no UI and no input binding. Your game shows the prompt and calls the component from its input. NsInteraction depends on no other plugin.

📦 Features

⚙️ Requirements

Unreal Engine 5.7+

🛠️ Installation

  1. Clone or download this repository.
  2. Copy the NsInteraction folder into the Plugins folder of your project.
  3. For C++, add "NsInteraction" to the dependencies of your game module in Build.cs.
  4. Generate the project files and enable the plugin.

🚀 Getting Started

  1. Make a Blueprint class with the parent NsInteractableActor. Add a static mesh to it.
  2. Implement the On Interact event, and place the actor in the level.
  3. On the player pawn, add the Ns Interaction and Ns Interaction View Sensor components. The pawn needs a camera.
  4. In the input of the pawn, call Begin Interact when the input starts and End Interact when it ends.
  5. Bind On Option Changed to show the prompt.

In C++, implement the interface on any actor:

// MyLever.h
#include "GameFramework/Actor.h"
#include "NsInteractable.h"
#include "MyLever.generated.h"

UCLASS()
class AMyLever : public AActor, public INsInteractable
{
    GENERATED_BODY()

public:
    virtual bool GetInteractionOption_Implementation(AActor* Interactor, UPrimitiveComponent* Part, FNsInteractionOption& OutOption) override
    {
        OutOption.Prompt = NSLOCTEXT("MyGame", "PullLever", "Pull the lever");
        return true;
    }

    virtual bool ExecuteInteraction_Implementation(AActor* Interactor, const FNsInteractionOption& Option) override
    {
        bPulled = !bPulled;
        return true;
    }

    bool bPulled = false;
};

🎯 Sensors

Sensor Setup
Aim Add a UNsInteractionViewSensor. It uses the first camera of the owner, or the component from SetViewSource
Nearby Add a sphere or box collision. Pass its overlap events to HandleSensorBeginOverlap and HandleSensorEndOverlap
Game code Call AddTarget, RemoveTarget, or SetTargets

🔧 API

🚧 Limits

📚 Documentation


Contact