Added additional check to the ledge grab
Signed-off-by: TjgL <lithmoneo@gmail.com>
This commit is contained in:
parent
54f45ad961
commit
e581fbd67c
BIN
Content/Legumix/Player/BP_Play.uasset
(Stored with Git LFS)
BIN
Content/Legumix/Player/BP_Play.uasset
(Stored with Git LFS)
Binary file not shown.
@ -283,11 +283,29 @@ void ALMPlayer::DoLedgeGrabCheck()
|
|||||||
FVector Dir = LedgeGrabOrigin->GetUpVector() * FVector(0, 0, -LedgeGrabTraceLength);
|
FVector Dir = LedgeGrabOrigin->GetUpVector() * FVector(0, 0, -LedgeGrabTraceLength);
|
||||||
FVector Ray = Origin + Dir;
|
FVector Ray = Origin + Dir;
|
||||||
|
|
||||||
|
EDrawDebugTrace::Type DrawDebug = bShowLedgeDebug ? EDrawDebugTrace::ForDuration : EDrawDebugTrace::None;
|
||||||
|
|
||||||
FHitResult Hit;
|
FHitResult Hit;
|
||||||
const bool Results = UKismetSystemLibrary::LineTraceSingleByProfile(GetWorld(), Origin, Ray, TEXT("BlockAll"), false
|
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)
|
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());
|
FVector TeleportLocation = FVector(Hit.Location.X, Hit.Location.Y, Hit.Location.Z + GetCapsuleComponent()->GetScaledCapsuleHalfHeight());
|
||||||
SetActorLocation(TeleportLocation, false, nullptr, ETeleportType::ResetPhysics);
|
SetActorLocation(TeleportLocation, false, nullptr, ETeleportType::ResetPhysics);
|
||||||
}
|
}
|
||||||
|
@ -217,6 +217,9 @@ private:
|
|||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Legumix, meta = (AllowPrivateAccess = true, ClampMin = 0.01f))
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Legumix, meta = (AllowPrivateAccess = true, ClampMin = 0.01f))
|
||||||
float CoyoteTimeLength = 0.5f;
|
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
|
* Actualize all parameters needed to calculate PlayerViewOcclusionPercent
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user