Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ADDED :: Driving v3
- // *************************************************************************** v0.1 // a29
- // *********************** 1st Gear + Accel + Brake ************************
- // ***************************************************************************
- float aDefaultLatScale = mAxle->getWheelOptions()->getLateralScale();
- // --- AXLE ---
- float aFrontWheels = mAxle->getIndex() == 0;
- float aRearWheels = mAxle->getIndex() == 1;
- float aBraking = mVehicle->getStandardInput()->getBrakeFinalInput(); // (0-1) Only by input.
- float aCurGear = mVehicle->getTransmission()->getCurGear(); // Get current gear
- float steerDeltaAngleR = mVehicle->getSteerDeltaAngle(false); // Rear angle difference
- float carAngleR = FMath::Abs(steerDeltaAngleR);
- float brakePow = 1.0f; // Max 1.0. Multiplier to manage overall power
- // Using getSteerDeltaAngle(false), due with true, in high turning the angle decreases instead of increase.
- // a29 || "/ 90.0f" :: Higher = More brake || Lower = Less brake.
- float brakeAngleR = FMath::Clamp(1.0f-(carAngleR / 90.0f), 0.0f, 1.0f);
- // Final brake calculation || Accel maybe should be added here too.
- float driftBrake = brakePow *brakeAngleR *aBraking;
- // Only on 1st gear + Braking when issue happens.
- if ( aCurGear == 1 && aBraking > 0.0f ) {
- mVehicle->getAxle(0)->getRightWheel()->setBraking(driftBrake);
- mVehicle->getAxle(0)->getLeftWheel()->setBraking( driftBrake);
- mVehicle->getAxle(1)->getRightWheel()->setBraking(driftBrake);
- mVehicle->getAxle(1)->getLeftWheel()->setBraking( driftBrake);
- // To make the car +slide/angle to compensate less braking.
- if ( aFrontWheels ) {
- mLatScale = aDefaultLatScale -(aBraking*0.2f);
- }
- if ( aRearWheels ) {
- mLatScale = aDefaultLatScale -(aBraking*0.4f);
- }
- }
- else { mLatScale = aDefaultLatScale; }
- // -----------------------------------------------------------------------
- // ***********************************************************************
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement