Bugfix Pressing E in Dialogue Stops Player from Moving

This commit is contained in:
Philip W 2023-05-19 02:20:15 +01:00
parent dcd4cbf356
commit 09b55ac425
5 changed files with 22 additions and 8 deletions

Binary file not shown.

BIN
Content/Levels/Build.umap (Stored with Git LFS)

Binary file not shown.

View File

@ -142,6 +142,7 @@ void UDialogueNPC::TickComponent(float DeltaTime, ELevelTick TickType, FActorCom
void UDialogueNPC::StartDialogue()
{
bIsInDialogue = true;
Quests.Empty();
BlueprintFunctions.Empty();
ItemIndexes.Empty();
@ -178,6 +179,7 @@ void UDialogueNPC::StartDialogue()
void UDialogueNPC::EndDialogue()
{
bIsInDialogue = false;
TextAnimationTimerHandle.Invalidate();
DialogueWidgetInstance->RemoveFromParent();

View File

@ -57,6 +57,9 @@ public:
UPROPERTY(EditAnywhere)
float TextAnimationSpeed = 0.05f;
UPROPERTY(BlueprintReadOnly)
bool bIsInDialogue = false;
protected:
// Called when the game starts
virtual void BeginPlay() override;
@ -92,14 +95,15 @@ private:
UPROPERTY()
UButton* NextButton;
UPROPERTY()
int DialogueIndex = 1;
UPROPERTY()
FString CurrentDialogue;
UPROPERTY()
FTimerHandle TextAnimationTimerHandle;
UFUNCTION()
void NextDialogue();
void NextCharacter();
UPROPERTY()
@ -122,10 +126,12 @@ public:
UFUNCTION(BlueprintCallable)
void StartDialogue();
UFUNCTION(BlueprintCallable)
void EndDialogue();
UFUNCTION(BlueprintCallable)
void NextDialogue();
UFUNCTION(BlueprintCallable)
UDialoguePath* CreateRootDialoguePath(bool ResetUserControls = true);

View File

@ -47,7 +47,13 @@ void UInteractNPC::Interact()
if (HitResult.GetActor()->Tags.Contains("NPC"))
{
//DrawDebugLine(GetWorld(), Start, End, FColor::Green, false, 5.0f, 0, 10.0f);
HitResult.GetActor()->FindComponentByClass<UDialogueNPC>()->StartDialogue();
UDialogueNPC* DialogueNPC = HitResult.GetActor()->FindComponentByClass<UDialogueNPC>();
if (DialogueNPC->bIsInDialogue)
{
DialogueNPC->NextDialogue();
return;
}
DialogueNPC->StartDialogue();
}
//DrawDebugLine(GetWorld(), Start, End, FColor::Red, false, 5.0f, 0, 10.0f);
}