Added additional check to the ledge grab

Signed-off-by: TjgL <lithmoneo@gmail.com>
This commit is contained in:
TjgL 2025-04-13 19:35:32 +02:00
parent 54f45ad961
commit e581fbd67c
3 changed files with 24 additions and 3 deletions

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

Binary file not shown.

View File

@ -283,11 +283,29 @@ void ALMPlayer::DoLedgeGrabCheck()
FVector Dir = LedgeGrabOrigin->GetUpVector() * FVector(0, 0, -LedgeGrabTraceLength);
FVector Ray = Origin + Dir;
EDrawDebugTrace::Type DrawDebug = bShowLedgeDebug ? EDrawDebugTrace::ForDuration : EDrawDebugTrace::None;
FHitResult Hit;
const bool Results = UKismetSystemLibrary::LineTraceSingleByProfile(GetWorld(), Origin, Ray, TEXT("BlockAll"), false
, {}, EDrawDebugTrace::None, Hit, true, FLinearColor::Red, FLinearColor::Green, 0.2f);
, {}, DrawDebug, Hit, true, FLinearColor::Red, FLinearColor::Green, 10.f);
if (Results)
{
FHitResult CapsuleCheck;
float HalfHeight = LegumixMovementComponent->bWantsToCrouch ? LegumixMovementComponent->CrouchedHalfHeight : GetCapsuleComponent()->GetScaledCapsuleHalfHeight();
const FVector Offset = Hit.ImpactPoint + FVector(0, 0, HalfHeight + GetCapsuleComponent()->GetScaledCapsuleRadius());
const bool IsObstructed = UKismetSystemLibrary::CapsuleTraceSingleByProfile(GetWorld(), Offset, Offset,
GetCapsuleComponent()->GetScaledCapsuleRadius(),
GetCapsuleComponent()->GetScaledCapsuleHalfHeight(), TEXT("BlockAll"), false,
{}, DrawDebug, CapsuleCheck, true, FLinearColor::Green, FLinearColor::Red, 10.f);
if (IsObstructed)
{
return;
// if (CapsuleCheck.ImpactPoint.Z > CapsuleCheck.Location.Z - HalfHeight)
// return;
}
FVector TeleportLocation = FVector(Hit.Location.X, Hit.Location.Y, Hit.Location.Z + GetCapsuleComponent()->GetScaledCapsuleHalfHeight());
SetActorLocation(TeleportLocation, false, nullptr, ETeleportType::ResetPhysics);
}

View File

@ -217,6 +217,9 @@ private:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Legumix, meta = (AllowPrivateAccess = true, ClampMin = 0.01f))
float CoyoteTimeLength = 0.5f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Legumix|LedgeGrab", meta = (AllowPrivateAccess = true, ClampMin = 0.f))
bool bShowLedgeDebug = false;
/**
* Actualize all parameters needed to calculate PlayerViewOcclusionPercent
*/