Skip to content

Commit

Permalink
Pushing required changes for more stable mantle velocity check
Browse files Browse the repository at this point in the history
  • Loading branch information
dyanikoglu committed Dec 1, 2020
1 parent 97ca23a commit 48c7390
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 20 deletions.
20 changes: 2 additions & 18 deletions Source/ALSV4_CPP/Private/Character/ALSBaseCharacter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -564,14 +564,6 @@ void AALSBaseCharacter::SetMovementModel()
MovementData = *OutRow;
}

bool AALSBaseCharacter::IsComponentVelocityValid(UPrimitiveComponent* PrimitiveComponent, float MaxVelocity)
{
FVector PrimitiveComponentVelocity = PrimitiveComponent->GetComponentVelocity();

return (PrimitiveComponentVelocity.Size() < MaxVelocity);
}


void AALSBaseCharacter::SetHasMovementInput(bool bNewHasMovementInput)
{
bHasMovementInput = bNewHasMovementInput;
Expand Down Expand Up @@ -1243,10 +1235,9 @@ bool AALSBaseCharacter::MantleCheck(const FALSMantleTraceSettings& TraceSettings
if (HitResult.GetComponent() != nullptr)
{
UPrimitiveComponent* PrimitiveComponent = HitResult.GetComponent();

if (!IsComponentVelocityValid(PrimitiveComponent, AcceptableVelocityWhileMantling))
if (PrimitiveComponent && PrimitiveComponent->GetComponentVelocity().Size() > AcceptableVelocityWhileMantling)
{
//The surface to mantle moves too fast
// The surface to mantle moves too fast
return false;
}
}
Expand Down Expand Up @@ -1321,13 +1312,6 @@ void AALSBaseCharacter::MantleUpdate(float BlendIn)
{
// Step 1: Continually update the mantle target from the stored local transform to follow along with moving objects
MantleTarget = UALSMathLibrary::MantleComponentLocalToWorld(MantleLedgeLS);

if (MantleLedgeLS.Component != nullptr && !IsComponentVelocityValid(MantleLedgeLS.Component, AcceptableVelocityWhileMantling))
{
//The surface to mantle moves too fast
MantleEnd();
return;
}

// Step 2: Update the Position and Correction Alphas using the Position/Correction curve set for each Mantle.
const FVector CurveVec = MantleParams.PositionCorrectionCurve
Expand Down
3 changes: 1 addition & 2 deletions Source/ALSV4_CPP/Public/Character/ALSBaseCharacter.h
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,6 @@ class ALSV4_CPP_API AALSBaseCharacter : public ACharacter

void SetMovementModel();

bool IsComponentVelocityValid(UPrimitiveComponent* PrimitiveComponent, float MaxVelocity);

/** Input */

void PlayerForwardMovementInput(float Value);
Expand Down Expand Up @@ -530,6 +528,7 @@ class ALSV4_CPP_API AALSBaseCharacter : public ACharacter
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "ALS|Mantle System")
UCurveFloat* MantleTimelineCurve;

/** If a dynamic object has a velocity bigger than value, do not start mantle */
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "ALS|Mantle System")
float AcceptableVelocityWhileMantling = 10.0f;

Expand Down

0 comments on commit 48c7390

Please sign in to comment.