diff --git a/Source/the_twilight_abyss/Dialogue/DialogueNPC.cpp b/Source/the_twilight_abyss/Dialogue/DialogueNPC.cpp index 74b35b0..725471f 100644 --- a/Source/the_twilight_abyss/Dialogue/DialogueNPC.cpp +++ b/Source/the_twilight_abyss/Dialogue/DialogueNPC.cpp @@ -4,6 +4,7 @@ #include "DialogueNPC.h" #include "Blueprint/UserWidget.h" #include "Components/TextBlock.h" +#include "GameFramework/Character.h" // Sets default values for this component's properties UDialogueNPC::UDialogueNPC() @@ -57,7 +58,7 @@ void UDialogueNPC::NextDialogue() void UDialogueNPC::NextCharacter() { if (DialogueIndex >= Dialogue.Num()) return; - + if (CurrentDialogue.Len() < Dialogue[DialogueIndex].Len()) { CurrentDialogue.AppendChar(Dialogue[DialogueIndex][CurrentDialogue.Len()]); @@ -75,11 +76,16 @@ void UDialogueNPC::TickComponent(float DeltaTime, ELevelTick TickType, FActorCom void UDialogueNPC::StartDialogue() { + //Disable Character Movement + if (ACharacter* PlayerCharacter = Cast(GetWorld()->GetFirstPlayerController()->GetPawn())) + { + PlayerCharacter->DisableInput(GetWorld()->GetFirstPlayerController()); + } //Set to UI Mode Only APlayerController* PlayerController = GetWorld()->GetFirstPlayerController(); PlayerController->SetInputMode(FInputModeUIOnly()); PlayerController->bShowMouseCursor = true; - + DialogueWidgetInstance->AddToViewport(); DialogueIndex = 0; NPCNameText->SetText(FText::FromString(NPCName)); @@ -92,6 +98,11 @@ void UDialogueNPC::EndDialogue() TextAnimationTimerHandle.Invalidate(); DialogueWidgetInstance->RemoveFromParent(); + //Enable Character Movement + if (ACharacter* PlayerCharacter = Cast(GetWorld()->GetFirstPlayerController()->GetPawn())) + { + PlayerCharacter->EnableInput(GetWorld()->GetFirstPlayerController()); + } //Reset UI Mode APlayerController* PlayerController = GetWorld()->GetFirstPlayerController(); PlayerController->SetInputMode(FInputModeGameOnly());