|
Post by Power Supersport on Mar 14, 2016 18:30:32 GMT
Hey, guys... This is the next part of Gearbox and the next video of the Game Modelling series... Experiment... It's always a good tip to play arround with values and stuff... Script needs to be explored... That's how I learned it... In this video I mostly try out some different values to achieve the most realistic gearbox behaviour... Subscribe to support me and my channel... And reply if you have something to say! PS: Big thanks to r for providing a fan art of the forum! Enjoy!
|
|
|
Post by Power Supersport on Mar 14, 2016 19:31:31 GMT
This is the script you need to implement the gearbox into your projects!
OBJ_0 - Car OBJ_22 - ValuePrint Gear (Optional)
int [] time(2);
int Gear; float rpm;
float speed = 3; // Basic speed float acceleration; float basicAcceleration = 1; // Basic acceleration
bool auto = true; // Set to false to disable the automatic transmission...
void Main() {
/// Gearbox
if (auto) { if ((IN_0 <= speed*3) and (IN_0 > 0)) Gear = 1; else if ((IN_0 <= speed*7) and (IN_0 > speed*3)) Gear = 2; else if ((IN_0 <= speed*10) and (IN_0 > speed*7)) Gear = 3; else if ((IN_0 <= speed*13) and (IN_0 > speed*10)) Gear = 4; else if ((IN_0 <= speed*16) and (IN_0 > speed*13)) Gear = 5; else if ((IN_0 <= speed*20) and (IN_0 > speed*16)) Gear = 6; }
else { if (iKeyDown(iKeyCode("DIK_A"))) { if (time[0] < 3) time[0] += 1; if (time[0] == 1) Gear += 1; } else time[0] = 0;
if (iKeyDown(iKeyCode("DIK_Z"))) { if (time[1] < 3) time[1] += 1; if (time[1] == 1) Gear -= 1; } else time[1] = 0; }
if (Gear <= 1) Gear = 1; if (Gear >= 6) Gear = 6;
if (Gear == 1) { acceleration = basicAcceleration * iFloatInterpolate(IN_0,0,speed*3,0.4,0.8,true); rpm = iFloatInterpolate(IN_0,0,speed*3,0.2,0.8,true); if (IN_0 > speed*3+1) OUT_2 = 1; else OUT_2 = 0; } else if (Gear == 2) { acceleration = basicAcceleration * iFloatInterpolate(IN_0,0,speed*7,0.3,1,true); rpm = iFloatInterpolate(IN_0,0,speed*7,0,0.8,true); if (IN_0 > speed*7+1) OUT_2 = 1; else OUT_2 = 0; } else if (Gear == 3) { acceleration = basicAcceleration * iFloatInterpolate(IN_0,0,speed*10,0.2,1,true); rpm = iFloatInterpolate(IN_0,0,speed*10,0,0.8,true); if (IN_0 > speed*10+1) OUT_2 = 1; else OUT_2 = 0; } else if (Gear == 4) { acceleration = basicAcceleration * iFloatInterpolate(IN_0,0,speed*13,0.2,1,true); rpm = iFloatInterpolate(IN_0,0,speed*13,0,0.8,true); if (IN_0 > speed*13+1) OUT_2 = 1; else OUT_2 = 0; } else if (Gear == 5) { acceleration = basicAcceleration * iFloatInterpolate(IN_0,0,speed*16,0.1,1,true); rpm = iFloatInterpolate(IN_0,0,speed*16,0,0.8,true); if (IN_0 > speed*16+1) OUT_2 = 1; else OUT_2 = 0; } else if (Gear == 6) { acceleration = basicAcceleration * iFloatInterpolate(IN_0,0,speed*20,0.05,0.95,true); rpm = iFloatInterpolate(IN_0,0,speed*20,0,0.8,true); if (IN_0 > speed*20+1) OUT_2 = 1; else OUT_2 = 0; }
OUT_3 = speed; OUT_4 = acceleration; }
|
|
|
Post by MonstaWolf on Mar 15, 2016 12:16:29 GMT
I have a script similar to that but I modified it to work as an automatic, as well as work with a PCar. Problem is, it often gets stuck at a high rpm, which can get annoying due to the noise.
|
|
|
Post by Power Supersport on Mar 15, 2016 16:35:18 GMT
Well, If you really get stuck you can use that one... I shared it because of you all...
|
|