From 29b06222a5fa77230b2e4df58fa9750129b14d41 Mon Sep 17 00:00:00 2001 From: baz Date: Mon, 25 Sep 2023 23:00:56 +0100 Subject: [PATCH] Add Pause Menu Widget to Player Character --- Source/Nakatomi/PlayerCharacter.cpp | 9 +++++++++ Source/Nakatomi/PlayerCharacter.h | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/Source/Nakatomi/PlayerCharacter.cpp b/Source/Nakatomi/PlayerCharacter.cpp index ebbb033..3a87ded 100644 --- a/Source/Nakatomi/PlayerCharacter.cpp +++ b/Source/Nakatomi/PlayerCharacter.cpp @@ -90,6 +90,11 @@ void APlayerCharacter::BeginPlay() currentPlayerHUD->AddToViewport(); } } + + if (PauseMenuWidget) + { + currentPauseMenuWidget = CreateWidget(GetWorld(), PauseMenuWidget); + } } void APlayerCharacter::Destroyed() @@ -489,6 +494,10 @@ void APlayerCharacter::EndAimDownSightsCallback(const FInputActionInstance& Inst void APlayerCharacter::PauseCallback(const FInputActionInstance& Instance) { + if (PauseMenuWidget) + { + // TODO: Add pause functionality + } } void APlayerCharacter::OnFire() diff --git a/Source/Nakatomi/PlayerCharacter.h b/Source/Nakatomi/PlayerCharacter.h index 82928fd..7d4323d 100644 --- a/Source/Nakatomi/PlayerCharacter.h +++ b/Source/Nakatomi/PlayerCharacter.h @@ -73,6 +73,9 @@ public: UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) TSubclassOf PlayerHUD; + UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) + TSubclassOf PauseMenuWidget; + FOnEnemyHitDelegate OnEnemyHit; protected: @@ -111,6 +114,8 @@ private: class UUserWidget* currentPlayerHUD; + UUserWidget* currentPauseMenuWidget; + UPROPERTY(EditAnywhere, BlueprintReadWrite, Meta = (AllowPrivateAccess = "true")) UAIPerceptionStimuliSourceComponent* PerceptionSource;