Add Slide Input Action

This commit is contained in:
baz 2024-01-12 15:30:55 +00:00
parent 293358737c
commit bf45b09cd7
7 changed files with 56 additions and 4 deletions

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

View File

@ -188,6 +188,16 @@ void UNakatomiCMC::DisableCrouch()
bWantsToCrouch = false; bWantsToCrouch = false;
} }
void UNakatomiCMC::EnableSlide()
{
EnterSlide();
}
void UNakatomiCMC::DisableSlide()
{
ExitSlide();
}
bool UNakatomiCMC::IsCustomMovementMode(ECustomMovementMove InCustomMovementMode) const bool UNakatomiCMC::IsCustomMovementMode(ECustomMovementMove InCustomMovementMode) const
{ {
return MovementMode == MOVE_Custom && CustomMovementMode == InCustomMovementMode; return MovementMode == MOVE_Custom && CustomMovementMode == InCustomMovementMode;

View File

@ -106,6 +106,12 @@ public:
UFUNCTION(BlueprintCallable) UFUNCTION(BlueprintCallable)
void DisableCrouch(); void DisableCrouch();
UFUNCTION(BlueprintCallable)
void EnableSlide();
UFUNCTION(BlueprintCallable)
void DisableSlide();
UFUNCTION() UFUNCTION()
bool IsCustomMovementMode(ECustomMovementMove InCustomMovementMode) const; bool IsCustomMovementMode(ECustomMovementMove InCustomMovementMode) const;

View File

@ -193,6 +193,12 @@ void APlayerCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputCom
Input->BindAction(CrouchAction, ETriggerEvent::Started, this, &APlayerCharacter::BeginCrouchCallback); Input->BindAction(CrouchAction, ETriggerEvent::Started, this, &APlayerCharacter::BeginCrouchCallback);
Input->BindAction(CrouchAction, ETriggerEvent::Completed, this, &APlayerCharacter::EndCrouchCallback); Input->BindAction(CrouchAction, ETriggerEvent::Completed, this, &APlayerCharacter::EndCrouchCallback);
} }
if (SlideAction)
{
Input->BindAction(SlideAction, ETriggerEvent::Started, this, &APlayerCharacter::BeginSlideCallback);
Input->BindAction(SlideAction, ETriggerEvent::Completed, this, &APlayerCharacter::EndSlideCallback);
}
} }
} }
@ -566,6 +572,26 @@ void APlayerCharacter::EndCrouchCallback(const FInputActionInstance& Instance)
} }
} }
void APlayerCharacter::BeginSlideCallback(const FInputActionInstance& Instance)
{
UNakatomiCMC* cmc = GetCharacterMovementComponent();
if (cmc)
{
cmc->EnableSlide();
}
}
void APlayerCharacter::EndSlideCallback(const FInputActionInstance& Instance)
{
UNakatomiCMC* cmc = GetCharacterMovementComponent();
if (cmc)
{
cmc->DisableSlide();
}
}
void APlayerCharacter::OnFire() void APlayerCharacter::OnFire()
{ {
if (!IsFiring || CurrentWeapon->GetAmmoCount() == 0) if (!IsFiring || CurrentWeapon->GetAmmoCount() == 0)

View File

@ -67,6 +67,9 @@ public:
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
UInputAction* CrouchAction; UInputAction* CrouchAction;
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
UInputAction* SlideAction;
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
TSoftObjectPtr<UInputMappingContext> InputMappingContext; TSoftObjectPtr<UInputMappingContext> InputMappingContext;
@ -181,6 +184,10 @@ public:
void BeginCrouchCallback(const FInputActionInstance& Instance); void BeginCrouchCallback(const FInputActionInstance& Instance);
void EndCrouchCallback(const FInputActionInstance& Instance); void EndCrouchCallback(const FInputActionInstance& Instance);
void BeginSlideCallback(const FInputActionInstance& Instance);
void EndSlideCallback(const FInputActionInstance& Instance);
virtual void OnFire() override; virtual void OnFire() override;