@@ -45,8 +45,9 @@ namespace gdjs {
45
45
_sharedData : gdjs . Physics3DSharedData ;
46
46
private _destroyedDuringFrameLogic : boolean = false ;
47
47
48
- _steerAngleMax = 30 ;
49
- private _steerAngularVelocity : float = 30 ;
48
+ _steerAngleMax = 70 ;
49
+ private _beginningSteerAngularVelocity : float = 35 ;
50
+ private _endSteerAngularVelocity : float = 5 ;
50
51
private _currentSteerRatio : float = 0 ;
51
52
52
53
private _hasPressedForwardKey : boolean = false ;
@@ -256,22 +257,28 @@ namespace gdjs {
256
257
? - 1.0
257
258
: 0.0 ;
258
259
259
- if ( ! this . _hasPressedLeftKey && ! this . _hasPressedRightKey ) {
260
+ if ( this . _hasPressedLeftKey === this . _hasPressedRightKey ) {
260
261
this . _currentSteerRatio = 0 ;
261
- }
262
- if ( this . _hasPressedLeftKey ) {
263
- // Avoid to much latency when changing of direction
264
- this . _currentSteerRatio = Math . min ( 0 , this . _currentSteerRatio ) ;
265
- this . _currentSteerRatio -=
266
- ( this . _steerAngularVelocity * timeDelta ) / this . _steerAngleMax ;
267
- this . _currentSteerRatio = Math . max ( - 1 , this . _currentSteerRatio ) ;
268
- }
269
- if ( this . _hasPressedRightKey ) {
270
- // Avoid to much latency when changing of direction
271
- this . _currentSteerRatio = Math . max ( 0 , this . _currentSteerRatio ) ;
272
- this . _currentSteerRatio +=
273
- ( this . _steerAngularVelocity * timeDelta ) / this . _steerAngleMax ;
274
- this . _currentSteerRatio = Math . min ( 1 , this . _currentSteerRatio ) ;
262
+ } else {
263
+ const steerAngularVelocity = gdjs . evtTools . common . lerp (
264
+ this . _beginningSteerAngularVelocity ,
265
+ this . _endSteerAngularVelocity ,
266
+ this . _currentSteerRatio
267
+ ) ;
268
+ if ( this . _hasPressedLeftKey ) {
269
+ // Avoid to much latency when changing of direction
270
+ this . _currentSteerRatio = Math . min ( 0 , this . _currentSteerRatio ) ;
271
+ this . _currentSteerRatio -=
272
+ ( steerAngularVelocity * timeDelta ) / this . _steerAngleMax ;
273
+ this . _currentSteerRatio = Math . max ( - 1 , this . _currentSteerRatio ) ;
274
+ }
275
+ if ( this . _hasPressedRightKey ) {
276
+ // Avoid to much latency when changing of direction
277
+ this . _currentSteerRatio = Math . max ( 0 , this . _currentSteerRatio ) ;
278
+ this . _currentSteerRatio +=
279
+ ( steerAngularVelocity * timeDelta ) / this . _steerAngleMax ;
280
+ this . _currentSteerRatio = Math . min ( 1 , this . _currentSteerRatio ) ;
281
+ }
275
282
}
276
283
277
284
if ( this . previousForward < 0 !== forward < 0 ) {
@@ -513,7 +520,7 @@ namespace gdjs {
513
520
const BR_WHEEL = 3 ;
514
521
515
522
const vehicleMass = 1500 ;
516
- const maxEngineTorque = 3000 ;
523
+ const maxEngineTorque = 1.5 * 3000 ;
517
524
const clutchStrength = 10 ;
518
525
519
526
const carShape = behavior . createShape ( ) ;
@@ -607,16 +614,16 @@ namespace gdjs {
607
614
608
615
const controllerSettings = new Jolt . WheeledVehicleControllerSettings ( ) ;
609
616
controllerSettings . mEngine . mMaxTorque = maxEngineTorque ;
610
- controllerSettings . mEngine . mMaxRPM = 1000 ;
617
+ // controllerSettings.mEngine.mMaxRPM = 1000;
611
618
controllerSettings . mEngine . mInertia = 0.01 ;
612
- controllerSettings . mEngine . mNormalizedTorque . Clear ( ) ;
613
- controllerSettings . mEngine . mNormalizedTorque . AddPoint ( 0 , 1 ) ;
614
- controllerSettings . mEngine . mNormalizedTorque . AddPoint ( 1 , 1 ) ;
619
+ // controllerSettings.mEngine.mNormalizedTorque.Clear();
620
+ // controllerSettings.mEngine.mNormalizedTorque.AddPoint(0, 1);
621
+ // controllerSettings.mEngine.mNormalizedTorque.AddPoint(1, 1);
615
622
controllerSettings . mTransmission . mClutchStrength = clutchStrength ;
616
- controllerSettings . mTransmission . mGearRatios . clear ( ) ;
617
- controllerSettings . mTransmission . mGearRatios . push_back ( 1 ) ;
618
- controllerSettings . mTransmission . mReverseGearRatios . clear ( ) ;
619
- controllerSettings . mTransmission . mReverseGearRatios . push_back ( - 1 ) ;
623
+ // controllerSettings.mTransmission.mGearRatios.clear();
624
+ // controllerSettings.mTransmission.mGearRatios.push_back(1);
625
+ // controllerSettings.mTransmission.mReverseGearRatios.clear();
626
+ // controllerSettings.mTransmission.mReverseGearRatios.push_back(-1);
620
627
621
628
vehicle . mController = controllerSettings ;
622
629
0 commit comments