Skip to main content

Start Quest Or Dialogue

Type: Requires external gameplay system

This example uses a complete quest-board actor and routes the interaction into your own quest or dialogue framework.

Example

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Data/EDInteractionTypes.h"
#include "MyQuestBoardActor.generated.h"

class UArrowComponent;
class UEDInteractableComponent;
class USceneComponent;
class UStaticMeshComponent;

UCLASS()
class AMyQuestBoardActor : public AActor
{
GENERATED_BODY()

public:
AMyQuestBoardActor();

protected:
virtual void BeginPlay() override;

UPROPERTY(VisibleAnywhere)
TObjectPtr<USceneComponent> Root;

UPROPERTY(VisibleAnywhere)
TObjectPtr<UStaticMeshComponent> BoardMesh;

UPROPERTY(VisibleAnywhere)
TObjectPtr<USceneComponent> WidgetHolder;

UPROPERTY(VisibleAnywhere)
TObjectPtr<UArrowComponent> CenterArrow;

UPROPERTY(VisibleAnywhere)
TObjectPtr<UEDInteractableComponent> InteractableComponent;

UPROPERTY(EditAnywhere, Category = "Quest")
FName QuestId = TEXT("Quest.Main.Intro");

UFUNCTION()
void HandleInteractionSuccessful(const FEDInteractionEventContext& Context);
};
#include "MyQuestBoardActor.h"

#include "Components/ArrowComponent.h"
#include "Components/EDInteractableComponent.h"
#include "Components/SceneComponent.h"
#include "Components/StaticMeshComponent.h"
#include "GameFramework/Pawn.h"

AMyQuestBoardActor::AMyQuestBoardActor()
{
Root = CreateDefaultSubobject<USceneComponent>(TEXT("Root"));
SetRootComponent(Root);

BoardMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("BoardMesh"));
BoardMesh->SetupAttachment(Root);
BoardMesh->ComponentTags.Add(FName(TEXT("DimensionComponent")));

WidgetHolder = CreateDefaultSubobject<USceneComponent>(TEXT("WidgetHolder"));
WidgetHolder->SetupAttachment(Root);
WidgetHolder->SetRelativeLocation(FVector(0.f, 0.f, 100.f));
WidgetHolder->ComponentTags.Add(FName(TEXT("WidgetHolderComponent")));

CenterArrow = CreateDefaultSubobject<UArrowComponent>(TEXT("CenterArrow"));
CenterArrow->SetupAttachment(BoardMesh);
CenterArrow->ComponentTags.Add(FName(TEXT("CenterComponent")));

InteractableComponent = CreateDefaultSubobject<UEDInteractableComponent>(TEXT("InteractableComponent"));
}

void AMyQuestBoardActor::BeginPlay()
{
Super::BeginPlay();
InteractableComponent->OnInteractionSuccessful.AddDynamic(this, &AMyQuestBoardActor::HandleInteractionSuccessful);
}

void AMyQuestBoardActor::HandleInteractionSuccessful(const FEDInteractionEventContext& Context)
{
APawn* InstigatorPawn = Context.Instigator ? Context.Instigator->GetPawn() : nullptr;
if (!InstigatorPawn)
{
return;
}

// Placeholder: replace with your own quest/dialogue subsystem.
UMyQuestSubsystem* QuestSubsystem = GetGameInstance()->GetSubsystem<UMyQuestSubsystem>();
if (!QuestSubsystem)
{
return;
}

QuestSubsystem->StartQuestForActor(QuestId, InstigatorPawn);
}

External dependency note

Quest and dialogue logic are not part of EDInteractionSystem. The plugin only provides the validated interaction trigger and context.