Add Slide Input Action
This commit is contained in:
parent
293358737c
commit
bf45b09cd7
Binary file not shown.
BIN
Content/Input/InputMappingContext.uasset (Stored with Git LFS)
BIN
Content/Input/InputMappingContext.uasset (Stored with Git LFS)
Binary file not shown.
BIN
Content/Player/PlayerCharacter.uasset (Stored with Git LFS)
BIN
Content/Player/PlayerCharacter.uasset (Stored with Git LFS)
Binary file not shown.
|
@ -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;
|
||||
|
|
|
@ -106,6 +106,12 @@ public:
|
|||
UFUNCTION(BlueprintCallable)
|
||||
void DisableCrouch();
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void EnableSlide();
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void DisableSlide();
|
||||
|
||||
UFUNCTION()
|
||||
bool IsCustomMovementMode(ECustomMovementMove InCustomMovementMode) const;
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -67,6 +67,9 @@ public:
|
|||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
UInputAction* CrouchAction;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
UInputAction* SlideAction;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
TSoftObjectPtr<UInputMappingContext> InputMappingContext;
|
||||
|
@ -181,6 +184,10 @@ public:
|
|||
void BeginCrouchCallback(const FInputActionInstance& Instance);
|
||||
|
||||
void EndCrouchCallback(const FInputActionInstance& Instance);
|
||||
|
||||
void BeginSlideCallback(const FInputActionInstance& Instance);
|
||||
|
||||
void EndSlideCallback(const FInputActionInstance& Instance);
|
||||
|
||||
virtual void OnFire() override;
|
||||
|
||||
|
|
Loading…
Reference in New Issue