diff --git a/Content/Input/Actions/IA_Slide.uasset b/Content/Input/Actions/IA_Slide.uasset new file mode 100644 index 0000000..952b084 --- /dev/null +++ b/Content/Input/Actions/IA_Slide.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:994df7bb660cf49d7f7dce90b19640070e8017a9b01d4f4889577c6ca55fb304 +size 1335 diff --git a/Content/Input/InputMappingContext.uasset b/Content/Input/InputMappingContext.uasset index 97ca042..4c35457 100644 --- a/Content/Input/InputMappingContext.uasset +++ b/Content/Input/InputMappingContext.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:de1d417c9d38a0a6340834b2e26be834ebb75b539bd8d6e3072f20b798a48a90 -size 20933 +oid sha256:a3a7a8439ad88551e785e4c83a04d9753526bf6fb24d900abd1b3a513b2df181 +size 21067 diff --git a/Content/Player/PlayerCharacter.uasset b/Content/Player/PlayerCharacter.uasset index 081877a..5e9b6ea 100644 --- a/Content/Player/PlayerCharacter.uasset +++ b/Content/Player/PlayerCharacter.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:744bb92f90935559c0e4c0f3f62f34cf45dddb5232be266360bcd1fbeefbe250 -size 41175 +oid sha256:587f042237e7a5d1f718068f17e6d94f9dd6133fadbd5bb3f8a4d652a1781adc +size 41366 diff --git a/Source/Nakatomi/NakatomiCMC.cpp b/Source/Nakatomi/NakatomiCMC.cpp index 93e92d8..efea661 100644 --- a/Source/Nakatomi/NakatomiCMC.cpp +++ b/Source/Nakatomi/NakatomiCMC.cpp @@ -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; diff --git a/Source/Nakatomi/NakatomiCMC.h b/Source/Nakatomi/NakatomiCMC.h index 49ac9a9..8ae8ceb 100644 --- a/Source/Nakatomi/NakatomiCMC.h +++ b/Source/Nakatomi/NakatomiCMC.h @@ -106,6 +106,12 @@ public: UFUNCTION(BlueprintCallable) void DisableCrouch(); + UFUNCTION(BlueprintCallable) + void EnableSlide(); + + UFUNCTION(BlueprintCallable) + void DisableSlide(); + UFUNCTION() bool IsCustomMovementMode(ECustomMovementMove InCustomMovementMode) const; diff --git a/Source/Nakatomi/PlayerCharacter.cpp b/Source/Nakatomi/PlayerCharacter.cpp index e17a04f..a79acd6 100644 --- a/Source/Nakatomi/PlayerCharacter.cpp +++ b/Source/Nakatomi/PlayerCharacter.cpp @@ -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) diff --git a/Source/Nakatomi/PlayerCharacter.h b/Source/Nakatomi/PlayerCharacter.h index 5f75c86..d042695 100644 --- a/Source/Nakatomi/PlayerCharacter.h +++ b/Source/Nakatomi/PlayerCharacter.h @@ -67,6 +67,9 @@ public: UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) UInputAction* CrouchAction; + + UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) + UInputAction* SlideAction; UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) TSoftObjectPtr 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;