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() void UDialogueNPC::StartDialogue()
{ {
bIsInDialogue = true;
Quests.Empty(); Quests.Empty();
BlueprintFunctions.Empty(); BlueprintFunctions.Empty();
ItemIndexes.Empty(); ItemIndexes.Empty();
@ -178,6 +179,7 @@ void UDialogueNPC::StartDialogue()
void UDialogueNPC::EndDialogue() void UDialogueNPC::EndDialogue()
{ {
bIsInDialogue = false;
TextAnimationTimerHandle.Invalidate(); TextAnimationTimerHandle.Invalidate();
DialogueWidgetInstance->RemoveFromParent(); DialogueWidgetInstance->RemoveFromParent();

View File

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

View File

@ -47,7 +47,13 @@ void UInteractNPC::Interact()
if (HitResult.GetActor()->Tags.Contains("NPC")) if (HitResult.GetActor()->Tags.Contains("NPC"))
{ {
//DrawDebugLine(GetWorld(), Start, End, FColor::Green, false, 5.0f, 0, 10.0f); //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); //DrawDebugLine(GetWorld(), Start, End, FColor::Red, false, 5.0f, 0, 10.0f);
} }