Add Pause Action

This commit is contained in:
baz 2025-01-24 22:35:12 +00:00
parent a00f453b87
commit 4294658f41
6 changed files with 33 additions and 4 deletions

BIN
Content/Input/IA_Pause.uasset (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Content/Input/IMC_Player.uasset (Stored with Git LFS)

Binary file not shown.

BIN
Content/Player/BP_PlayerController.uasset (Stored with Git LFS)

Binary file not shown.

View File

@ -25,6 +25,9 @@ public:
UFUNCTION(BlueprintCallable, BlueprintNativeEvent) UFUNCTION(BlueprintCallable, BlueprintNativeEvent)
void Input_Move(FVector2D value); void Input_Move(FVector2D value);
UFUNCTION(BlueprintCallable, BlueprintNativeEvent)
void Input_Pause();
UFUNCTION(BlueprintCallable, BlueprintNativeEvent) UFUNCTION(BlueprintCallable, BlueprintNativeEvent)
UInputMappingContext* Input_GetInputMappingContext(); UInputMappingContext* Input_GetInputMappingContext();

View File

@ -65,6 +65,7 @@ void AVampirePlayerController::SetupInputComponent()
if (UEnhancedInputComponent* EIP = CastChecked<UEnhancedInputComponent>(InputComponent)) if (UEnhancedInputComponent* EIP = CastChecked<UEnhancedInputComponent>(InputComponent))
{ {
EIP->BindAction(MovementAction, ETriggerEvent::Triggered, this, &AVampirePlayerController::Move); EIP->BindAction(MovementAction, ETriggerEvent::Triggered, this, &AVampirePlayerController::Move);
EIP->BindAction(PauseAction, ETriggerEvent::Triggered, this, &AVampirePlayerController::OnPause);
} }
} }
@ -81,6 +82,22 @@ void AVampirePlayerController::Move(const FInputActionValue& MovementInput)
} }
} }
void AVampirePlayerController::OnPause(const FInputActionValue& PauseInput)
{
if (APawn* pawn = GetPawn())
{
if (UKismetSystemLibrary::DoesImplementInterface(pawn, UInputable::StaticClass()))
{
IInputable::Execute_Input_Pause(pawn);
}
}
if (SetPause(true))
{
//TODO: Add pause screen
}
}
void AVampirePlayerController::UpdatePlayerEXPHUD(int exp, float currentLevelPercent) void AVampirePlayerController::UpdatePlayerEXPHUD(int exp, float currentLevelPercent)
{ {
if (currentPlayerHUD) if (currentPlayerHUD)

View File

@ -6,6 +6,7 @@
#include "GameFramework/PlayerController.h" #include "GameFramework/PlayerController.h"
#include "VampirePlayerController.generated.h" #include "VampirePlayerController.generated.h"
struct FInputActionValue;
class UInputAction; class UInputAction;
class UHUDWidget; class UHUDWidget;
/** /**
@ -25,6 +26,8 @@ public:
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
UInputAction* MovementAction; UInputAction* MovementAction;
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
UInputAction* PauseAction;
private: private:
@ -42,6 +45,9 @@ protected:
UFUNCTION() UFUNCTION()
void Move(const FInputActionValue& MovementInput); void Move(const FInputActionValue& MovementInput);
UFUNCTION()
void OnPause(const FInputActionValue& PauseInput);
UFUNCTION() UFUNCTION()
void UpdatePlayerEXPHUD(int exp, float currentLevelPercent); void UpdatePlayerEXPHUD(int exp, float currentLevelPercent);