Implemented slide inputs
Signed-off-by: TjgL <lithmoneo@gmail.com>
This commit is contained in:
parent
447dc6fbd4
commit
4cb72bb499
BIN
Content/Legumix/Player/BP_PlayerController.uasset
(Stored with Git LFS)
BIN
Content/Legumix/Player/BP_PlayerController.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Legumix/Player/Input/IA_Slide.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Legumix/Player/Input/IA_Slide.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Legumix/Player/Input/IMC_Default.uasset
(Stored with Git LFS)
BIN
Content/Legumix/Player/Input/IMC_Default.uasset
(Stored with Git LFS)
Binary file not shown.
@ -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,10 @@ void ULMMovementComponent::CrouchPressed()
|
||||
bWantsToCrouch = !bWantsToCrouch;
|
||||
}
|
||||
|
||||
void ULMMovementComponent::CrouchToggle(bool Toggle)
|
||||
{
|
||||
bWantsToCrouch = Toggle;
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
|
||||
|
@ -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());
|
||||
|
@ -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<ALMPlayer> PlayerCharacterOwner;
|
||||
@ -88,7 +93,4 @@ private:
|
||||
void ExitSlide();
|
||||
void PhysSlide(float DeltaTime, int32 Iterations);
|
||||
bool GetSlideSurface(FHitResult& Hit) const;
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="Legumix|Slide")
|
||||
void CrouchPressed();
|
||||
};
|
||||
|
@ -48,9 +48,13 @@ private:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = true))
|
||||
TObjectPtr<UInputAction> PauseAction;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = true))
|
||||
TObjectPtr<UInputAction> SlideAction;
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, meta = (AllowPrivateAccess = true))
|
||||
TObjectPtr<ALMPlayer> LegumixPlayer;
|
||||
|
||||
|
||||
virtual void SetupInputComponent() override;
|
||||
void Move(const FInputActionValue& InputValue);
|
||||
void Jump(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;
|
||||
|
Reference in New Issue
Block a user