I’m using Andrew Gatows, Vehicle physics for a experiment i have everything running smoothly except for gear change… The Vehicle is automatic but it won’t go past 2nd Gear. My Car has Gears… This is the shift gears part of my script.
function ShiftGears() {
// this funciton shifts the gears of the vehcile, it loops through all the gears, checking which will make
// the engine RPM fall within the desired range. The gear is then set to this "appropriate" value.
if ( EngineRPM >= MaxEngineRPM ) {
var AppropriateGear : int = CurrentGear;
for ( var i = 0; i < GearRatio.length; i ++ ) {
if ( FrontLeftWheel.rpm * GearRatio *< MaxEngineRPM ) {*
-
AppropriateGear = i;*
-
break;*
-
}*
-
}*
-
CurrentGear = AppropriateGear;*
-
}*
-
if ( EngineRPM <= MinEngineRPM ) {*
-
AppropriateGear = CurrentGear;*
-
for ( var j = GearRatio.length-1; j >= 0; j -- ) {*
_ if ( FrontLeftWheel.rpm * GearRatio[j] > MinEngineRPM ) {_
-
AppropriateGear = j;*
-
break;*
-
}*
-
}*
-
CurrentGear = AppropriateGear;*
-
}*
}
After some tinkering i found out the problem comes from this line.
rigidbody.drag = rigidbody.velocity.magnitude / 250;
This limits the cars “Speed” but is causing issues with shifting… Does someone know why this is? or how to resolve this issue?