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();
}
}
if (PauseMenuWidget)
{
currentPauseMenuWidget = CreateWidget<UUserWidget>(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()

View File

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