Skip to content

Commit

Permalink
Merge pull request #53 from VarLog/feature/turn-rate
Browse files Browse the repository at this point in the history
Add TurnRateModAngularSpeed modificator for Steering and MaxSpeed curves
  • Loading branch information
VarLog authored Jun 9, 2017
2 parents c6de4c5 + ec95e88 commit 31fd8f1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,10 @@ class PSREALVEHICLEPLUGIN_API UPrvVehicleMovementComponent : public UPawnMovemen
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = SteeringSetup, meta = (editcondition = "bAngularVelocitySteering", ClampMin = "0.0", UIMin = "0.0"))
float AutoBrakeSteeringThreshold;

/** Steering rotation angular speed modificator for SteeringCurve and MaxSpeedCurve */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = SteeringSetup, meta = (editcondition = "bAngularVelocitySteering", ClampMin = "0.0", UIMin = "0.0"))
float TurnRateModAngularSpeed;


/////////////////////////////////////////////////////////////////////////
// Brake system
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ UPrvVehicleMovementComponent::UPrvVehicleMovementComponent(const FObjectInitiali
AngularSteeringFrictionThreshold = 0.5f;
AutoBrakeSteeringThreshold = 5000.f;
bAutoBrakeSteering = false;
TurnRateModAngularSpeed = 0.f;

bUseSteeringCurve = false;
FRichCurve* SteeringCurveData = SteeringCurve.GetRichCurve();
Expand Down Expand Up @@ -587,8 +588,8 @@ void UPrvVehicleMovementComponent::UpdateSteering(float DeltaTime)
if (bUseSteeringCurve)
{
FRichCurve* SteeringCurveData = SteeringCurve.GetRichCurve();
const float SteeringCurveZeroPoint = FMath::Min(SteeringCurveData->Eval(0.f), SteeringAngularSpeed);
const float SteeringCurvePoint = FMath::Min(SteeringCurveData->Eval(CurrentSpeed), SteeringAngularSpeed);
const float SteeringCurveZeroPoint = FMath::Min(SteeringCurveData->Eval(0.f) + TurnRateModAngularSpeed, SteeringAngularSpeed);
const float SteeringCurvePoint = FMath::Min(SteeringCurveData->Eval(CurrentSpeed) + TurnRateModAngularSpeed, SteeringAngularSpeed);

if (bMaximizeZeroThrottleSteering && FMath::IsNearlyZero(RawThrottleInput))
{
Expand Down Expand Up @@ -949,7 +950,7 @@ void UPrvVehicleMovementComponent::UpdateBrake(float DeltaTime)
const float CurrentSpeed = UpdatedMesh->GetComponentVelocity().Size();

FRichCurve* MaxSpeedCurveData = MaxSpeedCurve.GetRichCurve();
const float MaxSpeedLimit = MaxSpeedCurveData->Eval(FMath::Abs(TargetSteeringAngularSpeed));
const float MaxSpeedLimit = MaxSpeedCurveData->Eval(FMath::Abs(TargetSteeringAngularSpeed) - TurnRateModAngularSpeed);

if (CurrentSpeed >= MaxSpeedLimit)
{
Expand Down Expand Up @@ -1060,7 +1061,7 @@ void UPrvVehicleMovementComponent::UpdateEngine()
if (bLimitMaxSpeed)
{
FRichCurve* MaxSpeedCurveData = MaxSpeedCurve.GetRichCurve();
const float MaxSpeedLimit = MaxSpeedCurveData->Eval(FMath::Abs(TargetSteeringAngularSpeed));
const float MaxSpeedLimit = MaxSpeedCurveData->Eval(FMath::Abs(TargetSteeringAngularSpeed) - TurnRateModAngularSpeed);

bLimitTorqueBySpeed = (CurrentSpeed >= MaxSpeedLimit);
}
Expand Down

0 comments on commit 31fd8f1

Please sign in to comment.