Implemented coyote time

Signed-off-by: TjgL <lithmoneo@gmail.com>
This commit is contained in:
TjgL 2025-03-28 18:04:58 +01:00
parent e797ecd8de
commit c913a7c00b
2 changed files with 26 additions and 1 deletions

View File

@ -113,7 +113,13 @@ int ALMPlayer::RemoveAmmo(const EAmmoType AmmoType, const int Count) const
bool ALMPlayer::CanJumpInternal_Implementation() const bool ALMPlayer::CanJumpInternal_Implementation() const
{ {
return JumpIsAllowedInternal(); return JumpIsAllowedInternal() || bIsInCoyoteTime;
}
void ALMPlayer::OnJumped_Implementation()
{
Super::OnJumped_Implementation();
bIsInCoyoteTime = false;
} }
void ALMPlayer::AddAmmo(const EAmmoType Ammo, const int AmmoCount) void ALMPlayer::AddAmmo(const EAmmoType Ammo, const int AmmoCount)
@ -245,6 +251,16 @@ void ALMPlayer::SetPlayerViewOcclusionPercent()
NextPlayerViewOcclusionPercent = CumulatedDamagesOnCurrentHitPeriod / HealthAtTheCurrentHitPeriodBeginning; NextPlayerViewOcclusionPercent = CumulatedDamagesOnCurrentHitPeriod / HealthAtTheCurrentHitPeriodBeginning;
} }
void ALMPlayer::OnWalkingOffLedge_Implementation(const FVector& PreviousFloorImpactNormal,
const FVector& PreviousFloorContactNormal, const FVector& PreviousLocation, float TimeDelta)
{
Super::OnWalkingOffLedge_Implementation(PreviousFloorImpactNormal, PreviousFloorContactNormal, PreviousLocation,
TimeDelta);
bIsInCoyoteTime = true;
GetWorldTimerManager().SetTimer(CoyoteCheckTimer, this, &ALMPlayer::FinishCoyoteTime, CoyoteTimeLength, false);
}
void ALMPlayer::MovementChanged(ACharacter* Character, EMovementMode PrevMovementMode, uint8 PreviousCustomMode) void ALMPlayer::MovementChanged(ACharacter* Character, EMovementMode PrevMovementMode, uint8 PreviousCustomMode)
{ {
if (GetCharacterMovement()->MovementMode == MOVE_Falling) if (GetCharacterMovement()->MovementMode == MOVE_Falling)

View File

@ -56,6 +56,7 @@ public:
int RemoveAmmo(EAmmoType AmmoType, int Count) const; int RemoveAmmo(EAmmoType AmmoType, int Count) const;
virtual bool CanJumpInternal_Implementation() const override; virtual bool CanJumpInternal_Implementation() const override;
virtual void OnJumped_Implementation() override;
UFUNCTION(BlueprintCallable) UFUNCTION(BlueprintCallable)
void AddAmmo(EAmmoType Ammo, int AmmoCount); void AddAmmo(EAmmoType Ammo, int AmmoCount);
@ -210,6 +211,9 @@ private:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Legumix|LedgeGrab", meta = (AllowPrivateAccess = true, ClampMin = 0.f)) UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Legumix|LedgeGrab", meta = (AllowPrivateAccess = true, ClampMin = 0.f))
float LedgeGrabTraceLength = 44.f; float LedgeGrabTraceLength = 44.f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Legumix, meta = (AllowPrivateAccess = true, ClampMin = 0.01f))
float CoyoteTimeLength = 0.5f;
/** /**
* Actualize all parameters needed to calculate PlayerViewOcclusionPercent * Actualize all parameters needed to calculate PlayerViewOcclusionPercent
*/ */
@ -222,6 +226,9 @@ private:
UFUNCTION(BlueprintCallable, Category=PostProcess) UFUNCTION(BlueprintCallable, Category=PostProcess)
void SetPlayerViewOcclusionPercent(); void SetPlayerViewOcclusionPercent();
void OnWalkingOffLedge_Implementation(const FVector& PreviousFloorImpactNormal, const FVector& PreviousFloorContactNormal, const FVector& PreviousLocation, float TimeDelta) override;
void FinishCoyoteTime() { bIsInCoyoteTime = false; }
private: private:
#if WITH_EDITORONLY_DATA #if WITH_EDITORONLY_DATA
/** If set, bullet debug will be drawn. */ /** If set, bullet debug will be drawn. */
@ -232,4 +239,6 @@ private:
private: private:
FRandomStream SpreadStream; FRandomStream SpreadStream;
FTimerHandle LedgeGrabCheckTimer; FTimerHandle LedgeGrabCheckTimer;
FTimerHandle CoyoteCheckTimer;
bool bIsInCoyoteTime;
}; };