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;
}
void UNakatomiCMC::EnableSlide()
{
EnterSlide();
}
void UNakatomiCMC::DisableSlide()
{
ExitSlide();
}
bool UNakatomiCMC::IsCustomMovementMode(ECustomMovementMove InCustomMovementMode) const
{
return MovementMode == MOVE_Custom && CustomMovementMode == InCustomMovementMode;

View File

@ -106,6 +106,12 @@ public:
UFUNCTION(BlueprintCallable)
void DisableCrouch();
UFUNCTION(BlueprintCallable)
void EnableSlide();
UFUNCTION(BlueprintCallable)
void DisableSlide();
UFUNCTION()
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::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()
{
if (!IsFiring || CurrentWeapon->GetAmmoCount() == 0)

View File

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