Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TurnRateModAngularSpeed modificator for Steering and MaxSpeed curves #53

Merged
merged 1 commit into from
Jun 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[steering] Add TurnRateModAngularSpeed modificator for Steering MaxSp…
…eed curves
  • Loading branch information
VarLog committed Jun 9, 2017
commit ec95e88dca557ab76d2375539cc3eab138182d0d
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