Updated DialogueNPC to Disable Character Movement

This commit is contained in:
Philip W 2023-02-02 02:39:35 +00:00
parent 3433254463
commit 5c5b915225

View File

@ -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()
@ -75,6 +76,11 @@ void UDialogueNPC::TickComponent(float DeltaTime, ELevelTick TickType, FActorCom
void UDialogueNPC::StartDialogue()
{
//Disable Character Movement
if (ACharacter* PlayerCharacter = Cast<ACharacter>(GetWorld()->GetFirstPlayerController()->GetPawn()))
{
PlayerCharacter->DisableInput(GetWorld()->GetFirstPlayerController());
}
//Set to UI Mode Only
APlayerController* PlayerController = GetWorld()->GetFirstPlayerController();
PlayerController->SetInputMode(FInputModeUIOnly());
@ -92,6 +98,11 @@ void UDialogueNPC::EndDialogue()
TextAnimationTimerHandle.Invalidate();
DialogueWidgetInstance->RemoveFromParent();
//Enable Character Movement
if (ACharacter* PlayerCharacter = Cast<ACharacter>(GetWorld()->GetFirstPlayerController()->GetPawn()))
{
PlayerCharacter->EnableInput(GetWorld()->GetFirstPlayerController());
}
//Reset UI Mode
APlayerController* PlayerController = GetWorld()->GetFirstPlayerController();
PlayerController->SetInputMode(FInputModeGameOnly());