diff --git a/Content/Legumix/Player/BP_Play.uasset b/Content/Legumix/Player/BP_Play.uasset index 140163f..7279fab 100644 --- a/Content/Legumix/Player/BP_Play.uasset +++ b/Content/Legumix/Player/BP_Play.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9dd8c29e151540a7946527d205f95f023b0023d3f7dbf4128187d7a680e93fed -size 499564 +oid sha256:e8ff5ba2e6aec9103e8f4ac9870ea0be05c2276bab8e514f6f31b35ec3831860 +size 489617 diff --git a/Content/Legumix/Player/BP_PlayerController.uasset b/Content/Legumix/Player/BP_PlayerController.uasset index c402d84..12d2476 100644 --- a/Content/Legumix/Player/BP_PlayerController.uasset +++ b/Content/Legumix/Player/BP_PlayerController.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:504abdca2dc1731389651a842f3516c2512c3ef3652815c8b38fdbbe54d2b7cf -size 22113 +oid sha256:fc92081abb28b81e9a56e981284c3e7802f559c318716fe4c5d2f2bba749c6e3 +size 22303 diff --git a/Content/Legumix/Player/Input/IA_Slide.uasset b/Content/Legumix/Player/Input/IA_Slide.uasset new file mode 100644 index 0000000..db3c2b8 --- /dev/null +++ b/Content/Legumix/Player/Input/IA_Slide.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:038f57ce28cb8a93ff67bf7170ad62bbea268dd9c23ad31e8d2f2704ec0b91f6 +size 1387 diff --git a/Content/Legumix/Player/Input/IMC_Default.uasset b/Content/Legumix/Player/Input/IMC_Default.uasset index 4b3c94f..46ed3f6 100644 --- a/Content/Legumix/Player/Input/IMC_Default.uasset +++ b/Content/Legumix/Player/Input/IMC_Default.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e6f482de1b0f1d01b8addd6aa98e2bb9a0ad4213e5de92813b461299370dd4a5 -size 9979 +oid sha256:d0ff97e52ef57a81cb0874011e2cb04e2b80d485e8b65ef64bff423e0dd6611f +size 10659 diff --git a/Source/LegumeMix/Private/Player/LMMovementComponent.cpp b/Source/LegumeMix/Private/Player/LMMovementComponent.cpp index 5fbd0d6..506e546 100644 --- a/Source/LegumeMix/Private/Player/LMMovementComponent.cpp +++ b/Source/LegumeMix/Private/Player/LMMovementComponent.cpp @@ -116,11 +116,9 @@ bool ULMMovementComponent::CanCrouchInCurrentState() const void ULMMovementComponent::UpdateCharacterStateBeforeMovement(float DeltaSeconds) { - UE_LOG(LogTemp, Log, TEXT("Velocity %f vs %f"), Velocity.SizeSquared(), pow(SlideMinSpeed, 2)) if (MovementMode == EMovementMode::MOVE_Walking && Safe_bPrevWantsToCrouch) { FHitResult PotentialSlideSurface; - UE_LOG(LogTemp, Display, TEXT("PotentialSlideSurface")); if (Velocity.SizeSquared() > pow(SlideMinSpeed, 2) && GetSlideSurface(PotentialSlideSurface)) { EnterSlide(); @@ -260,5 +258,16 @@ void ULMMovementComponent::CrouchPressed() bWantsToCrouch = !bWantsToCrouch; } +void ULMMovementComponent::CrouchToggle(bool Toggle) +{ + bWantsToCrouch = Toggle; +} + #pragma endregion +bool ULMMovementComponent::CanAttemptJump() const +{ + return IsJumpAllowed() && + (IsMovingOnGround() || IsFalling()); // Falling included for double-jump and non-zero jump hold time, but validated by character. +} + diff --git a/Source/LegumeMix/Private/Player/LMPlayer.cpp b/Source/LegumeMix/Private/Player/LMPlayer.cpp index 1973219..0f93264 100644 --- a/Source/LegumeMix/Private/Player/LMPlayer.cpp +++ b/Source/LegumeMix/Private/Player/LMPlayer.cpp @@ -105,6 +105,11 @@ int ALMPlayer::RemoveAmmo(const EAmmoType AmmoType, const int Count) const return WeaponManager->RemoveAmmo(AmmoType, Count); } +bool ALMPlayer::CanJumpInternal_Implementation() const +{ + return JumpIsAllowedInternal(); +} + void ALMPlayer::SetWeaponManager(ULMWeaponManager* Manager) { UE_LOG(LogTemp, Warning, TEXT("Set weapon manager")) diff --git a/Source/LegumeMix/Private/Player/LMPlayerController.cpp b/Source/LegumeMix/Private/Player/LMPlayerController.cpp index 94eb9f8..06e4911 100644 --- a/Source/LegumeMix/Private/Player/LMPlayerController.cpp +++ b/Source/LegumeMix/Private/Player/LMPlayerController.cpp @@ -7,6 +7,7 @@ #include "LMUserSettings.h" #include "GameFramework/Character.h" #include "Kismet/GameplayStatics.h" +#include "Player/LMMovementComponent.h" #include "Player/LMPlayer.h" #include "Weapon/LMWeaponManager.h" @@ -35,6 +36,8 @@ void ALMPlayerController::SetupInputComponent() Input->BindAction(ReloadAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Reload); Input->BindAction(ScrollAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Scroll); Input->BindAction(PauseAction, ETriggerEvent::Triggered, this, &ALMPlayerController::TogglePause); + Input->BindAction(SlideAction, ETriggerEvent::Started, this, &ALMPlayerController::SlideInput); + Input->BindAction(SlideAction, ETriggerEvent::Completed, this, &ALMPlayerController::SlideCancel); } } @@ -79,6 +82,19 @@ void ALMPlayerController::PauseInput(const FInputActionValue& InputValue) TogglePause(); } +void ALMPlayerController::SlideInput(const FInputActionValue& InputValue) +{ + LegumixPlayer->GetLegumixMovementComponent()->CrouchToggle(true); +} + +void ALMPlayerController::SlideCancel(const FInputActionValue& InputValue) +{ + if (LegumixPlayer->GetLegumixMovementComponent()->bWantsToCrouch) + { + LegumixPlayer->GetLegumixMovementComponent()->CrouchToggle(false); + } +} + void ALMPlayerController::TogglePause() { const bool bIsPaused = UGameplayStatics::IsGamePaused(GetWorld()); diff --git a/Source/LegumeMix/Public/Player/LMMovementComponent.h b/Source/LegumeMix/Public/Player/LMMovementComponent.h index 5382b96..8d5f1ff 100644 --- a/Source/LegumeMix/Public/Player/LMMovementComponent.h +++ b/Source/LegumeMix/Public/Player/LMMovementComponent.h @@ -66,6 +66,11 @@ public: UFUNCTION(BlueprintPure) bool IsCustomMovementMode(ECustomMovementModes InCustomMovementMode) const; + UFUNCTION(BlueprintCallable, Category="Legumix|Slide") + void CrouchPressed(); + UFUNCTION(BlueprintCallable, Category="Legumix|Slide") + void CrouchToggle(bool Toggle); + public: UPROPERTY(Transient) TObjectPtr PlayerCharacterOwner; @@ -87,8 +92,6 @@ private: void EnterSlide(); void ExitSlide(); void PhysSlide(float DeltaTime, int32 Iterations); - bool GetSlideSurface(FHitResult& Hit) const; - - UFUNCTION(BlueprintCallable, Category="Legumix|Slide") - void CrouchPressed(); + bool GetSlideSurface(FHitResult& Hit) const; + virtual bool CanAttemptJump() const override; }; diff --git a/Source/LegumeMix/Public/Player/LMPlayer.h b/Source/LegumeMix/Public/Player/LMPlayer.h index deaf8e3..32d5236 100644 --- a/Source/LegumeMix/Public/Player/LMPlayer.h +++ b/Source/LegumeMix/Public/Player/LMPlayer.h @@ -53,6 +53,8 @@ public: UFUNCTION(BlueprintCallable) int RemoveAmmo(EAmmoType AmmoType, int Count) const; + virtual bool CanJumpInternal_Implementation() const override; + protected: // Called when the game starts or when spawned virtual void BeginPlay() override; diff --git a/Source/LegumeMix/Public/Player/LMPlayerController.h b/Source/LegumeMix/Public/Player/LMPlayerController.h index 58f1ab6..8497837 100644 --- a/Source/LegumeMix/Public/Player/LMPlayerController.h +++ b/Source/LegumeMix/Public/Player/LMPlayerController.h @@ -47,9 +47,13 @@ private: UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = true)) TObjectPtr PauseAction; + + UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = true)) + TObjectPtr SlideAction; UPROPERTY(BlueprintReadOnly, meta = (AllowPrivateAccess = true)) TObjectPtr LegumixPlayer; + virtual void SetupInputComponent() override; void Move(const FInputActionValue& InputValue); @@ -59,6 +63,8 @@ private: void Reload(const FInputActionValue& InputValue); void Scroll(const FInputActionValue& InputValue); void PauseInput(const FInputActionValue& InputValue); + void SlideInput(const FInputActionValue& InputValue); + void SlideCancel(const FInputActionValue& InputValue); UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Legumix, meta = (AllowPrivateAccess = true, UIMin=0.01, ClampMin=0.01, UIMax=10.0, ClampMax=10.0)) float Sensitivity = 1.0f;