diff --git a/Content/Legumix/Player/BP_Play.uasset b/Content/Legumix/Player/BP_Play.uasset index 099de9f..1c933c7 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:afcadbb313be0cd15c4e326c756d83a0de86b0a76ebb4720e69e5a60dac3dc4d -size 713087 +oid sha256:7a4f92a92c0ec69de7372bb1d84c99045289f6d16e294c4510588044e9950325 +size 709359 diff --git a/Source/LegumeMix/Private/Player/LMPlayer.cpp b/Source/LegumeMix/Private/Player/LMPlayer.cpp index e0634ac..3728f62 100644 --- a/Source/LegumeMix/Private/Player/LMPlayer.cpp +++ b/Source/LegumeMix/Private/Player/LMPlayer.cpp @@ -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); } diff --git a/Source/LegumeMix/Public/Player/LMPlayer.h b/Source/LegumeMix/Public/Player/LMPlayer.h index 55d8524..50d7c22 100644 --- a/Source/LegumeMix/Public/Player/LMPlayer.h +++ b/Source/LegumeMix/Public/Player/LMPlayer.h @@ -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 */