Add Pause Menu Widget to Player Character

This commit is contained in:
baz 2023-09-25 23:00:56 +01:00
parent 322b872042
commit 29b06222a5
2 changed files with 14 additions and 0 deletions

View File

@ -90,6 +90,11 @@ void APlayerCharacter::BeginPlay()
currentPlayerHUD->AddToViewport(); currentPlayerHUD->AddToViewport();
} }
} }
if (PauseMenuWidget)
{
currentPauseMenuWidget = CreateWidget<UUserWidget>(GetWorld(), PauseMenuWidget);
}
} }
void APlayerCharacter::Destroyed() void APlayerCharacter::Destroyed()
@ -489,6 +494,10 @@ void APlayerCharacter::EndAimDownSightsCallback(const FInputActionInstance& Inst
void APlayerCharacter::PauseCallback(const FInputActionInstance& Instance) void APlayerCharacter::PauseCallback(const FInputActionInstance& Instance)
{ {
if (PauseMenuWidget)
{
// TODO: Add pause functionality
}
} }
void APlayerCharacter::OnFire() void APlayerCharacter::OnFire()

View File

@ -73,6 +73,9 @@ public:
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
TSubclassOf<class UUserWidget> PlayerHUD; TSubclassOf<class UUserWidget> PlayerHUD;
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
TSubclassOf<class UUserWidget> PauseMenuWidget;
FOnEnemyHitDelegate OnEnemyHit; FOnEnemyHitDelegate OnEnemyHit;
protected: protected:
@ -111,6 +114,8 @@ private:
class UUserWidget* currentPlayerHUD; class UUserWidget* currentPlayerHUD;
UUserWidget* currentPauseMenuWidget;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Meta = (AllowPrivateAccess = "true")) UPROPERTY(EditAnywhere, BlueprintReadWrite, Meta = (AllowPrivateAccess = "true"))
UAIPerceptionStimuliSourceComponent* PerceptionSource; UAIPerceptionStimuliSourceComponent* PerceptionSource;