Merge remote-tracking branch 'origin/master'

This commit is contained in:
Emilie Schott 2025-03-12 12:50:00 +01:00
commit 0d8d83e0cf
10 changed files with 56 additions and 12 deletions

BIN
Content/Legumix/Player/BP_Play.uasset (Stored with Git LFS)

Binary file not shown.

Binary file not shown.

BIN
Content/Legumix/Player/Input/IA_Slide.uasset (Stored with Git LFS) Normal file

Binary file not shown.

Binary file not shown.

View File

@ -116,11 +116,9 @@ bool ULMMovementComponent::CanCrouchInCurrentState() const
void ULMMovementComponent::UpdateCharacterStateBeforeMovement(float DeltaSeconds) 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) if (MovementMode == EMovementMode::MOVE_Walking && Safe_bPrevWantsToCrouch)
{ {
FHitResult PotentialSlideSurface; FHitResult PotentialSlideSurface;
UE_LOG(LogTemp, Display, TEXT("PotentialSlideSurface"));
if (Velocity.SizeSquared() > pow(SlideMinSpeed, 2) && GetSlideSurface(PotentialSlideSurface)) if (Velocity.SizeSquared() > pow(SlideMinSpeed, 2) && GetSlideSurface(PotentialSlideSurface))
{ {
EnterSlide(); EnterSlide();
@ -260,5 +258,16 @@ void ULMMovementComponent::CrouchPressed()
bWantsToCrouch = !bWantsToCrouch; bWantsToCrouch = !bWantsToCrouch;
} }
void ULMMovementComponent::CrouchToggle(bool Toggle)
{
bWantsToCrouch = Toggle;
}
#pragma endregion #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.
}

View File

@ -105,6 +105,11 @@ int ALMPlayer::RemoveAmmo(const EAmmoType AmmoType, const int Count) const
return WeaponManager->RemoveAmmo(AmmoType, Count); return WeaponManager->RemoveAmmo(AmmoType, Count);
} }
bool ALMPlayer::CanJumpInternal_Implementation() const
{
return JumpIsAllowedInternal();
}
void ALMPlayer::SetWeaponManager(ULMWeaponManager* Manager) void ALMPlayer::SetWeaponManager(ULMWeaponManager* Manager)
{ {
UE_LOG(LogTemp, Warning, TEXT("Set weapon manager")) UE_LOG(LogTemp, Warning, TEXT("Set weapon manager"))

View File

@ -7,6 +7,7 @@
#include "LMUserSettings.h" #include "LMUserSettings.h"
#include "GameFramework/Character.h" #include "GameFramework/Character.h"
#include "Kismet/GameplayStatics.h" #include "Kismet/GameplayStatics.h"
#include "Player/LMMovementComponent.h"
#include "Player/LMPlayer.h" #include "Player/LMPlayer.h"
#include "Weapon/LMWeaponManager.h" #include "Weapon/LMWeaponManager.h"
@ -35,6 +36,8 @@ void ALMPlayerController::SetupInputComponent()
Input->BindAction(ReloadAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Reload); Input->BindAction(ReloadAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Reload);
Input->BindAction(ScrollAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Scroll); Input->BindAction(ScrollAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Scroll);
Input->BindAction(PauseAction, ETriggerEvent::Triggered, this, &ALMPlayerController::TogglePause); 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(); 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() void ALMPlayerController::TogglePause()
{ {
const bool bIsPaused = UGameplayStatics::IsGamePaused(GetWorld()); const bool bIsPaused = UGameplayStatics::IsGamePaused(GetWorld());

View File

@ -66,6 +66,11 @@ public:
UFUNCTION(BlueprintPure) UFUNCTION(BlueprintPure)
bool IsCustomMovementMode(ECustomMovementModes InCustomMovementMode) const; bool IsCustomMovementMode(ECustomMovementModes InCustomMovementMode) const;
UFUNCTION(BlueprintCallable, Category="Legumix|Slide")
void CrouchPressed();
UFUNCTION(BlueprintCallable, Category="Legumix|Slide")
void CrouchToggle(bool Toggle);
public: public:
UPROPERTY(Transient) UPROPERTY(Transient)
TObjectPtr<ALMPlayer> PlayerCharacterOwner; TObjectPtr<ALMPlayer> PlayerCharacterOwner;
@ -88,7 +93,5 @@ private:
void ExitSlide(); void ExitSlide();
void PhysSlide(float DeltaTime, int32 Iterations); void PhysSlide(float DeltaTime, int32 Iterations);
bool GetSlideSurface(FHitResult& Hit) const; bool GetSlideSurface(FHitResult& Hit) const;
virtual bool CanAttemptJump() const override;
UFUNCTION(BlueprintCallable, Category="Legumix|Slide")
void CrouchPressed();
}; };

View File

@ -53,6 +53,8 @@ public:
UFUNCTION(BlueprintCallable) UFUNCTION(BlueprintCallable)
int RemoveAmmo(EAmmoType AmmoType, int Count) const; int RemoveAmmo(EAmmoType AmmoType, int Count) const;
virtual bool CanJumpInternal_Implementation() const override;
protected: protected:
// Called when the game starts or when spawned // Called when the game starts or when spawned
virtual void BeginPlay() override; virtual void BeginPlay() override;

View File

@ -48,9 +48,13 @@ private:
UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = true)) UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = true))
TObjectPtr<UInputAction> PauseAction; TObjectPtr<UInputAction> PauseAction;
UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = true))
TObjectPtr<UInputAction> SlideAction;
UPROPERTY(BlueprintReadOnly, meta = (AllowPrivateAccess = true)) UPROPERTY(BlueprintReadOnly, meta = (AllowPrivateAccess = true))
TObjectPtr<ALMPlayer> LegumixPlayer; TObjectPtr<ALMPlayer> LegumixPlayer;
virtual void SetupInputComponent() override; virtual void SetupInputComponent() override;
void Move(const FInputActionValue& InputValue); void Move(const FInputActionValue& InputValue);
void Jump(const FInputActionValue& InputValue); void Jump(const FInputActionValue& InputValue);
@ -59,6 +63,8 @@ private:
void Reload(const FInputActionValue& InputValue); void Reload(const FInputActionValue& InputValue);
void Scroll(const FInputActionValue& InputValue); void Scroll(const FInputActionValue& InputValue);
void PauseInput(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)) UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Legumix, meta = (AllowPrivateAccess = true, UIMin=0.01, ClampMin=0.01, UIMax=10.0, ClampMax=10.0))
float Sensitivity = 1.0f; float Sensitivity = 1.0f;