diff --git a/Content/Blueprints/Combat_UI/CombatCharacter.uasset b/Content/Blueprints/Combat_UI/CombatCharacter.uasset index 3b2c174..52a81f0 100644 --- a/Content/Blueprints/Combat_UI/CombatCharacter.uasset +++ b/Content/Blueprints/Combat_UI/CombatCharacter.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:585edb5a7d5ed873e905c5150c3d20757177b5741d22806730b54a47415d472d -size 72618 +oid sha256:485e33d984b8f741004f9015747b2ee40af6302886ae4f62d49ae13a32cb42a4 +size 81511 diff --git a/Content/Dialogue/DialogueTest.umap b/Content/Dialogue/DialogueTest.umap index 4a0c8c3..f2a5797 100644 --- a/Content/Dialogue/DialogueTest.umap +++ b/Content/Dialogue/DialogueTest.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:911ac1a22605bd25c09862336710dd077c849e1bcbeb4046c70cd1e9ef698ff7 -size 41447 +oid sha256:6f2c0cc2d73c9fd35cf193c48ae0546bd41a9a10dedfe8c60d504fe09b55e819 +size 41343 diff --git a/Content/Dialogue/NPCTest.uasset b/Content/Dialogue/NPCTest.uasset index cdd38f9..8bcd011 100644 --- a/Content/Dialogue/NPCTest.uasset +++ b/Content/Dialogue/NPCTest.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0594afb06d0d1957dd84c2ee2ee8487e30962a5bc85fad7ac1deb64cd3586552 -size 30359 +oid sha256:721d5229ead581f3db621f16f64292467e4f049587194e59b3c23343e61076c8 +size 31202 diff --git a/Source/the_twilight_abyss/Dialogue/DialogueNPC.cpp b/Source/the_twilight_abyss/Dialogue/DialogueNPC.cpp index 725471f..cc5535b 100644 --- a/Source/the_twilight_abyss/Dialogue/DialogueNPC.cpp +++ b/Source/the_twilight_abyss/Dialogue/DialogueNPC.cpp @@ -29,8 +29,6 @@ void UDialogueNPC::BeginPlay() DialogueText = Cast(DialogueWidgetInstance->GetWidgetFromName("Text_Dialogue")); NextButton = Cast(DialogueWidgetInstance->GetWidgetFromName("Button_Next")); NextButton->OnClicked.AddDynamic(this, &UDialogueNPC::NextDialogue); - - StartDialogue(); } diff --git a/Source/the_twilight_abyss/Dialogue/InteractNPC.cpp b/Source/the_twilight_abyss/Dialogue/InteractNPC.cpp new file mode 100644 index 0000000..32ba171 --- /dev/null +++ b/Source/the_twilight_abyss/Dialogue/InteractNPC.cpp @@ -0,0 +1,54 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "InteractNPC.h" +#include "DialogueNPC.h" + + +// Sets default values for this component's properties +UInteractNPC::UInteractNPC() +{ + // Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features + // off to improve performance if you don't need them. + PrimaryComponentTick.bCanEverTick = true; + + // ... +} + + +// Called when the game starts +void UInteractNPC::BeginPlay() +{ + Super::BeginPlay(); + + // ... + +} + + +// Called every frame +void UInteractNPC::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) +{ + Super::TickComponent(DeltaTime, TickType, ThisTickFunction); + + // ... +} + +void UInteractNPC::Interact() +{ + FVector Start = GetOwner()->GetActorLocation(); + FVector End = GetOwner()->GetActorForwardVector() * 100.0f + Start; + FCollisionQueryParams CollisionParams; + CollisionParams.AddIgnoredActor(GetOwner()); + if (FHitResult HitResult; GetWorld()->LineTraceSingleByChannel(HitResult, Start, End, ECC_Pawn, CollisionParams)) + { + //UE_LOG(LogTemp, Warning, TEXT("Hit: %s"), *HitResult.GetActor()->GetName()); + if (HitResult.GetActor()->Tags.Contains("NPC")) + { + //DrawDebugLine(GetWorld(), Start, End, FColor::Green, false, 5.0f, 0, 10.0f); + HitResult.GetActor()->FindComponentByClass()->StartDialogue(); + } + //DrawDebugLine(GetWorld(), Start, End, FColor::Red, false, 5.0f, 0, 10.0f); + } +} + diff --git a/Source/the_twilight_abyss/Dialogue/InteractNPC.h b/Source/the_twilight_abyss/Dialogue/InteractNPC.h new file mode 100644 index 0000000..6c76b27 --- /dev/null +++ b/Source/the_twilight_abyss/Dialogue/InteractNPC.h @@ -0,0 +1,29 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "Components/ActorComponent.h" +#include "InteractNPC.generated.h" + + +UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent)) +class THE_TWILIGHT_ABYSS_API UInteractNPC : public UActorComponent +{ + GENERATED_BODY() + +public: + // Sets default values for this component's properties + UInteractNPC(); + +protected: + // Called when the game starts + virtual void BeginPlay() override; + +public: + // Called every frame + virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override; + + UFUNCTION(BlueprintCallable) + void Interact(); +};