Garry's Mod

Garry's Mod

Not enough ratings
Vehicle Scripts for Source
By Kalimando
How vehicle scripting parameters for Garrysmod, and the source engine in general work.

Since they way these values are translated is engine (or even havok) level the only way to truly understand how they work was to do some standard tests on a map in Garrysmod.
   
Award
Favorite
Favorited
Unfavorite
General Info
Formatting
  • ] test parameter
  • # raw data from a test run
  • > observations from a test or all runs in a test
  • ) observations from data or info outside of a test
  • % statements and assumptions gathered from a test
  • } statements to consider for future tests
  • + statements to consider for an entire batch of tests

The sections following the quickstart guide is from a text document I was typing into while testing some variables of the vehicles scripting system. I typed my thoughts after each test and if you just want to know how to do things yourself just use the quickstart guide and results sections
Results
Now that I am actually making models and testing the effects of wheel spacing, wheel radius, and mass there is some rough guidelines I would suggest.

  • The shape (mesh) of the car is a non-issue, and even the physics hull (collision model) shape doesn't matter much for wheeled cars because you can override both the mass and the origin of the mass

  • The radius of a wheel becomes a sphere and not a cylinder. The player will not collide with it, and the vehicles own collision model wont collide with it, but the terrain and props will. Keep this in mind while working on large vehicles with narrow wheels
Motorcycles are a not possible. Make a vehicle skeleton where the front and back wheels are close together or straight up centered and give it a whirl. This works on paper, and even drives straight forward just fine. However the way a real motorcycle steers is by leaning the vehicle to the side so the wheel's contact points are at two different diameters (sloped) thus causing a turn. We barely turn the front wheel of a motorbike, which is why it can be attached at such an extreme angle to the body of the vehicle. We cannot do this with the vehicle implementation we have so its actually more suited to lua based solutions. Tricycles and other 3poc vehicles could totally work however. I have yet to try having the front steering wheels placed behind the rear ones (forklift style) but that may have interesting effects.


Rules of thumb for the line items
-rpm, shiftuprpm, shift downrpm
Just leave these at 3k, 1-2.5k, and 500-1.5k respectively. I couldn't find where all the math is done with these parameters in the sourcecode so it must be engine level. If you feel you must change them, do it last

-horsepower, maxspeed, axleratio, torquefactor, addgravity, masscenteroverride, massoverride, gear, suspension

These are your primary tools for really changing the attributes of a vehicle. In fact if you are interested in making vehicles I would suggest just using the buggy as I did to start and fiddling with these values.


  • The mass and its center are the first thing you need to decide for your vehicle. Using a real value for the kg of the mass is actually a good place to start. Then try and set the center of mass in a realistic place for the vehicle. The buggy has this set behind the seat and you notice its effects most harshly when jumping off of a ramp (and immediately flipping). Try and resist the urge to just make it the center as well, because cars which handle perfectly are no fun.

  • The reason we start with the mass/center is because it directly affects the second most important parts... the suspension. The "springconstant" for the axle closest to the mass center will need to be higher the closer it gets to it. If a car weighs 1000kg and all of that mass is directly above the front axle, the spring will need to be fairly strong to support it. Likewise the opposite axle will reqire less springconstant the further it is from the center. Aside from that, you can adjust the "springdamping" "stabilizerconstant" and "springdampingcompression" to have the suspension either be really stable, or bouncy and reactive. Keep in mind also that the more bouncy the suspension is, the less stable the vehicle becomes at high speeds. Also try to adjust the "springconstant" so that both the front and back axles are at their middle/center rest animation. If the springs are too weak to hold the mass up animations can break. While too stiff a spring and the car will react to pushes far too strongly, (fast enough to kill too). Worth considering also is the "addgravity" parameter which pushes down the mass. This value can be just about anything but I find the buggy/jalopy default of .5 is pretty good for making a decent car. Vehicles in source hate being anything but 180degrees upside down or rightside up and its almost impossible to disable the auto-righting of the car so keep this in mind when making narrow or short vehicles.

  • Now we have a car which reacts well to being dropped, we adjust the torquefactor between front and back axles. The value is a ratio between front and back so the two should always add up to 1. I would love to have all my cars just be 1/0 .5/.5 or 0/1 but they just don't handle that well. If you plan on having it FWD/RWD try starting with a ratio of .9/.1 and getting closer to .75/.25 with testing. From a personal experience, the image of the car for this guide is extremely front heavy, but since it is RWD I tried doing 1/0 with it. Since almost no mass was riding on the mover wheels the darn thing could barely move. Since we essentially are putting all the mass at a single point, the law of leavers makes the front wheels ideal for all the torque. As I mentioned in my experiment notes its the one thing contraptions have over these simulated vehicles is having multiple mass locations. All this is to say that you may have to fudge the "torquefactor" or the masscenter to get the vehicle to handle properly. With this in mind, 4WD would ideally have the mass centered, RWD and FWD with the mass directly above, BUT do not forget that all the mass is located at the center, so your vehicle will flip extremely easily if the masscenter is actually located at the zenith of a wheel's axle.

  • second to last but not least we have all the engine properties. "Maxspeed" is independant of velocity limiters determined by servers, but actually traveling faster than 78MPH/126KPH requires using the engine boost commands or a flat drive longer than even flatgrass can provide. I set this to 200 for four wheeled cars (refer to steering section for more). Horsepower is your raw rpm generator. Increasing HP increases your generation of RPM, and your RPM gets converted to speed by way of a gear's ratio and the axle ratio. You might consider leaving axleratio at 4.56 and just adjusting the horsepower and gears to find a good acceleration curve. I suspect the game-engine simply converts all these values into an acceleration curve anyways since there is no loss of speed or "shifting gaps" when going all out.

  • Perhaps most important but last to be adjusted, Steering. If you, like me, want your vehicles to go faster than 35mph you will need to change the steering values. Cranking the wheels 30 degrees at 120mph is a great way to spin out, but since all steering is keyboard input you will need to change how the steering curve works. "degreesslow" should be determined by how many degrees the vehicle model's animations go. I have a tank which is 90 at slow since treded vehicles can spin in place while a ratrod like the one above can only go about 28 degrees before the wheels clip the body. Then the next most important is "slowcarspeed" and "fastcarspeed" These determine when to flip from "degreesslow" to "degreesfast" and are in MPH. 40-30 degrees should be fine from 0-35mph, but from there your "degreesfast" should be in the single digits if you hope to maintain control. You can also change the "slowsteeringrate" "steeringrestrateslow" parameters to be how fast holding A or D goes from center to fully rotated steering, as well as their equivalent fast vatiations. Important also is something you must have noticed while driving the jeep. "turnthrottlereduceslow" "turnthrottlereducefast" are an additional tweek which actually reduces your speed when steering is happening by a percent.




How-To or Quickstart Guide
So you want to start your own vehicle testing? Here is what you need-to-know

in garrysmod/lua/autorun folder is a file called base_vehicles (this ships with the default game)

copy this file, rename it to something else, and have the file contain just this

local function AddVehicle( t, class ) list.Set( "Vehicles", class, t ) end local Category = "Half-Life 2" AddVehicle( { -- Required information Name = "My Test Vehicle", Model = "models/buggy.mdl", Class = "prop_vehicle_jeep_old", Category = Category, -- Optional information Author = "Me", Information = "Im making my own vehicles now", KeyValues = { vehiclescript = "scripts/my_test_vehicle.txt" } }, "My Test Vehicle" )

Then goto or create the scripts folder in you gmod directory where you see materials, models, and lua folder.

Inside this scripts folder make a new text file with the name my_test_vehicle.txt and paste this into it. This is the info for the default buggy in gmod.

"vehicle" { "wheelsperaxle" "2" "body" { "countertorquefactor" "0.9" "massCenterOverride" "0 -30 12" "massoverride" "1000" // kg "addgravity" "0.50" "maxAngularVelocity" "720" } "engine" { "horsepower" "350" "maxrpm" "4200" "maxspeed" "35" // mph "maxReverseSpeed" "14" // mph "autobrakeSpeedGain" "1.1" // 10% speed gain while coasting, put on the brakes after that "autobrakeSpeedFactor" "3.0" // Brake is this times the speed gain "autotransmission" "1" "axleratio" "4.56" "gear" "3.2" // 1st gear "gear" "2.4" // 2nd gear "gear" "1.5" // 3rd gear "gear" "1.0" // 4th gear "gear" "0.84" // 5th gear "shiftuprpm" "3800" "shiftdownrpm" "1600" "boost" { "force" "1.5" // 1.5 car body mass * gravity * inches / second ^ 2 "duration" "3.0" // 3.0 second of boost "delay" "3.0" // 3 seconds before you can use it again "torqueboost" "1" // enable "sprint" mode of vehicle, not force type booster "maxspeed" "50" // maximum turbo speed } } "steering" { "degreesSlow" "50" // steering cone at zero to slow speed "degreesFast" "18" // steering cone at fast speed to max speed "degreesBoost" "11" // steering cone at max boost speed (blend toward this after max speed) "steeringExponent" "1.4" // steering function is linear, then raised to this power to be slower at the beginning of the curve, faster at the end "slowcarspeed" "14" "fastcarspeed" "20" "slowSteeringRate" "4.0" "fastSteeringRate" "2.0" "steeringRestRateSlow" "4.0" "steeringRestRateFast" "2.0" "turnThrottleReduceSlow" "0.01" "turnThrottleReduceFast" "2.0" "brakeSteeringRateFactor" "6" "throttleSteeringRestRateFactor" "2" "boostSteeringRestRateFactor" "1.7" "boostSteeringRateFactor" "1.7" "powerSlideAccel" "250" "skidallowed" "1" "dustcloud" "1" } // front axle "axle" { "wheel" { "radius" "18" "mass" "100" "damping" "0" "rotdamping" "0.0" "material" "jeeptire" "skidmaterial" "slidingrubbertire" "brakematerial" "brakingrubbertire" } "suspension" { "springConstant" "40" "springDamping" "0.7" "stabilizerConstant" "10" "springDampingCompression" "9" "maxBodyForce" "9" } "torquefactor" "0.3" "brakefactor" "0.4" } // rear axle "axle" { "wheel" { "radius" "22" "mass" "100" "damping" "0" "rotdamping" "0.0" "material" "jeeptire" "skidmaterial" "slidingrubbertire" "brakematerial" "brakingrubbertire" } "suspension" { "springConstant" "40" "springDamping" "0.7" "stabilizerConstant" "10" "springDampingCompression" "9" "maxBodyForce" "9" } "torquefactor" "0.7" "brakefactor" "0.6" } } "vehicle_sounds" { // List gears in order from lowest speed to highest speed "gear" { "max_speed" "0.27" "speed_approach_factor" "1.0" } "gear" { "max_speed" "0.5" "speed_approach_factor" "0.05" } "gear" { "max_speed" "0.75" "speed_approach_factor" "0.052" } "gear" { "max_speed" "0.95" "speed_approach_factor" "0.034" } "gear" { "max_speed" "1.5" "speed_approach_factor" "0.033" } "gear" { "max_speed" "2.0" "speed_approach_factor" "0.03" } "state" { "name" "SS_START_WATER" "sound" "ATV_start_in_water" } "state" { "name" "SS_START_IDLE" "sound" "ATV_engine_start" "min_time" "4.0" } "state" { "name" "SS_SHUTDOWN_WATER" "sound" "ATV_stall_in_water" } "state" { "name" "SS_IDLE" "sound" "ATV_engine_idle" } "state" { "name" "SS_REVERSE" "sound" "ATV_reverse" "min_time" "0.5" } "state" { "name" "SS_GEAR_0" "sound" "ATV_rev" "min_time" "0.5" } "state" { "name" "SS_GEAR_0_RESUME" "sound" "ATV_engine_idle" "min_time" "0.75" } "state" { "name" "SS_GEAR_1" "sound" "ATV_firstgear" "min_time" "0.5" } "state" { "name" "SS_GEAR_1_RESUME" "sound" "ATV_firstgear_noshift" "min_time" "0.5" } "state" { "name" "SS_GEAR_2" "sound" "ATV_secondgear" "min_time" "0.5" } "state" { "name" "SS_GEAR_2_RESUME" "sound" "ATV_secondgear_noshift" "min_time" "0.5" } "state" { "name" "SS_GEAR_3" "sound" "ATV_thirdgear" "min_time" "0.5" } "state" { "name" "SS_GEAR_3_RESUME" "sound" "ATV_thirdgear_noshift" "min_time" "0.5" } "state" { "name" "SS_GEAR_4" "sound" "ATV_fourthgear" "min_time" "0.5" } "state" { "name" "SS_GEAR_4_RESUME" "sound" "ATV_fourthgear_noshift" "min_time" "0.5" } "state" { "name" "SS_SLOWDOWN_HIGHSPEED" "sound" "ATV_throttleoff_fastspeed" "min_time" "2.0" } "state" { "name" "SS_SLOWDOWN" "sound" "ATV_throttleoff_slowspeed" "min_time" "2.0" } "state" { "name" "SS_TURBO" "sound" "ATV_turbo_on" "min_time" "2.5" } "state" { "name" "SS_SHUTDOWN" "sound" "ATV_engine_stop" } "crashsound" { "min_speed" "350" "min_speed_change" "250" "sound" "ATV_impact_medium" "gear_limit" "1" } "crashsound" { "min_speed" "450" "min_speed_change" "350" "sound" "ATV_impact_heavy" } "skid_lowfriction" "ATV_skid_lowfriction" "skid_normalfriction" "ATV_skid_normalfriction" "skid_highfriction" "ATV_skid_highfriction" }

Without even decompiling a model or opening a GCF you can now play around with the parameters and make your own personal car. At some point I may make a guide on modeling a simple car and setting that up so keep an eye out!
Batch A Tests 1, 2, and 3
BATCH A BATCH A BATCH A BATCH A BATCH A BATCH A The v-scripts relevant info for tests 1-2-3-4 "countertorquefactor" "0.9" "massCenterOverride" "0 -30 12" "massoverride" "1000" // kg "addgravity" "0.50" "maxAngularVelocity" "720" "horsepower" "425" "maxrpm" "7000" "maxspeed" "135" // mph "maxReverseSpeed" "23" // mph "autobrakeSpeedGain" "1.1" // 10% speed gain while coasting, put on the brakes after that "autobrakeSpeedFactor" "3.0" // Brake is this times the speed gain "autotransmission" "1" "axleratio" "$:$$" // The tested variable for this batch "gear" "3.6" // 1st gear "gear" "2.37" // 2nd gear "gear" "1.55" // 3rd gear "gear" "0.85" // 4th gear "gear" "0.67" // 5th gear "shiftuprpm" "4500" "shiftdownrpm" "1200" +The altered variable for this and following tests is the "axleratio." +The low medium and high vehicles (models/buggy.mdl) are to be "axleratio" 2, 3, and 4. +Based on cursory research of this term used in real automotives, a higher axle ratio can give more torque at the cost of acceleration. +I chose to test this variable first based on the illusive effects it has had on acceleration when playing around with gears +The gear ratios I chose above are based loosely on a dodge charger aside from the first gear. Test Number 1 Acceleration Test Number 1 Acceleration Test Number 1 Acceleration Test Number 1 Acceleration Test Number 1 Acceleration
Test Number 1 Acceleration
}DARK RPM }Look into RPM and the shiftrpm commands next as these are extremely hard to nail down in their relation to horsepower and acceleration. ]The vehicle will run a course half the distance of Flatgrass ]times are recorded with the race editor featured with "s-cars." ]tested vehicles are using Hl2 system (jeep/airboat) and added via the use of lua as they are with the base vehicles, no special entites or code is applied #run - Low (2) achieved 15:32 with no sprint #run - med (3) achieved 13:85 with no sprint #run - high (4) achieved 13:22 with no sprint >Low appeared to have the most trouble with getting from the first gear to the second >Friction provided by the grass on flatgrass is assumed to be (0.8) as it is with dirt and other grass materials. )The airboat vehicle responds to friction but it may be worth testing if the jeep does as well later )The EP2 charger has a very high GR of 4.56 which lines up with the speed I see from the high tester here )Test performed with sv_maxvelocity at 3500, however maxspeed seems to overide effect of this. %From this data I am willing to assume the axleratio is reversed or ♥♥♥♥♥♥ up as 3 and 4 axleratios faired far quicker than 2, but the gears may have also played a role Test Number 2 Torque Test Number 2 Torque Test Number 2 Torque Test Number 2 Torque Test Number 2 Torque
Test Number 2 Torque
+Using the same stats as test 1 ]The vehicle will idle within 16 units of collision with the prop ]The vehicle will attempt to move models/props_c17/furnitureStove001a.mdl without sprint "The Heat" >All vehicles fail to move this prop without a lead-up but will quickly come to a stop after colliding and attempting to push it further >Friction of the surfaces may play a hand, I will stick to metal props which make metal hitsounds >the low medium and high vehicles show similar acceleration profiles to Test Number 1 when capable of moving a prop. Test Number 3 Torque Revised Test Number 3 Torque Revised Test Number 3 Torque Revised Test Number 3 Torque Revised Test Number 3 Torque Revised
Test Number 3 Torque Revised
)Under the assumption that the "countertorquefactor" command is set to 0.9 and affecting results )I then assume 0.9 is equivalent to a 90% reduction in torque output by the vphysics hull )The EP2 vehicle has this set to 0, many hills present in EP2 driving areas? )The gear ratios are all within 1-2 for EP2? it shifts through four or so gears very quickly just going from 0-35 (maxspeed 35 in its script) )The axleratio of 4.56 seems to make up for the EP2 charger's lack of torque in the gears, but a high ratio should increase torque and reduce acceleration not increase both? )EP2 charger's gears all being around the same is just to fake the acceleration being good? when the car moves slowly by our real world standards? To break up the audio? +next test this value is reduced to 0 for all testers ]The vehicle will idle within 16 units of collision with the prop ]The vehicle will attempt to move models/props_junk/TrashDumpster02.mdl without sprint "Big Blue" #run - low vehicle attempting to push the broad side will come to a stop #run - med vehicle attempting to push the broad side will come to a stop #run - high vehicle attempting to push the broad side will push slowly at first but accelerate to higher speeds and continue to push, even with only one or so units between >As I suspected the countertorquefactor had affected Test Number 2. >The reduction meant there was still a difference between the three vehicles, but the prop used to test would have a very small "goldylocks" zone where I could detect the difference in torque. %Tempting as it is to simply have countertorquefactor set to 0 for all vehicles it can be useful when creating small or fragile vehicles such as our HL2 jeep %perhaps the very reason the jeep has it set to .9 is because its just a sandrail with no "real" mass to it %HLMV gives its phys hull as around 800kg, and they increase it with commands above to 1000, but the volume of the rails and engine would be tiny for the chassis and huge for the engine more accurately done %Center-of-mass calc is very basic in a single hull situation, its why our contraptions usually act more realisticly (different masses connected rather than one homogenous mass) %The HL2 jeep probably can't be simulated well with its mass ditribution, so they give it a huge mass (1000) then diminish the effect that mass has with the countertorquefactor. %Certain vehicles will never be capable of moving a large object, conversely even a 1200 horsepower tractor needs traction and mass to really exert itself to move earth. %HL2 isnt spintires, when a vehicle cant move forward its wheels stop moving, it doesnt spin out }TWRQUE }within the suspension subheaders there is a torque factor assigned to each axle each adds up to 1 for both hl2 jeep and ep2 charger }The HL2 jeep appears to have rear wheel drive as its rear axle has .7 while the front gets .3 }The EP2 charger appears to have front wheel drive as its rear axle has .2 while the front gets .8 }worth testing a true 4WD and giving each .5, or having one be .95 and testing the results in the future }TORK }Torque is also necessary for vehicles that need to travel up inclined planes }The mass itself should work against the force of the wheels pushing the car up a hill }And yet the radius of the wheels, the ratio of the first gear, and the horsepower should also have a noticable effect as well }AUTOMAT }All the car scripts have the potential to switch from automatic to manual shifting, but no binds exist in the engine. }Perhaps this is the one area where lua based solutions have the edge, as many non-americans prefer it }Garry add +shiftup +shiftdown pls
Batch A Test 4
TEST NUMBER 4 GREEN HILL TORQUE ZONE TEST NUMBER 4 GREEN HILL TORQUE ZONE TEST NUMBER 4 GREEN HILL TORQUE ZONE TEST NUMBER 4 GREEN HILL TORQUE ZONE TEST NUMBER 4 GREEN HILL TORQUE ZONE
TEST NUMBER 4
GREEN HILL TORQUE ZONE +All the variables retain their modified values +A map is loaded with various inclines ranging from 45 at the steepest and decreasing by 6.4 degrees per plane until 22 degrees with eight planes total +trig wasnt my thing ]Vehicles will align themselves to the planes and attempt to drive straight up the surface without sprint ]The EP2 charger will be included after H for comparison ]The Airboat will be included after the charger for comparison ]The default HL2 jeep will be included after the airboat for comparison ]Data will be in a matrix and given pass P or fail F.(45d) to (22.8d) left to right. Additional notes to follow 0#1#2#3#4#5#6#7#8# L-F#F#F#F#F#F#F#F# M-F#F#F#F#F#F#F#F# H-F#F#F#F#F#P#P#P# C-F#F#F#P#P#P#P#P# A-F#F#F#P#P#P#P#P# J-F#F#F#P#P#P#P#P# >Truly amazing how simple this seems to have become >The default vehicles are more than capable of Handling the 25d angle but not the ones I created. >All three of the default vehicles have an axleratio of around 4.56 #set the high tester vehicle's axle ratio to 9 just to see the results >With a ratio of 9 it is impossible to spin out or lose control of the vehicle >Sharp turns will slow the vehicle but control will be maintained %axleratio seems to be a white-lie name for a traction/friction constant %An inrease in friction would account for both the increasing acceleration and ability to push props of greater mass %Appears to still be limited by either the mass and/or Horsepower %Might be simpler to adjust axleratio last since it has a large effect on the handling %Giving the high tester and absurd Horsepower of 1900 resulted in the improved handling blowing up, now it cant drive straight for more than a second }So many little things to consider
Batch B Tests 5 and 6
BATCH B BATCH B BATCH B BATCH B BATCH B BATCH B The v-scripts relevant info for tests 5 "body" { "countertorquefactor" "0" "massCenterOverride" "0 -30 12" "massoverride" "1000" // kg "maxAngularVelocity" "720" } "engine" { "horsepower" "$$$" // The Tested Variable for this batch "maxrpm" "3000" "maxspeed" "135" // mph "maxReverseSpeed" "23" // mph "autobrakeSpeedGain" "1.1" // 10% speed gain while coasting, put on the brakes after that "autobrakeSpeedFactor" "3.0" // Brake is this times the speed gain "autotransmission" "1" "axleratio" "4.56" // Some kind of traction control for the wheel ray-caster. Increases acceleration AND Torque "gear" "4" // 1st gear "gear" "3" // 2nd gear "gear" "2" // 3rd gear "gear" "1" // 4th gear "gear" "0.5" // 5th gear "shiftuprpm" "1500" "shiftdownrpm" "300" +Many of the values have been changed to simpler values and the rpm mirrors the EP2 Charger +As obeserved in previous the prevous test, horsepower does seem to have a noticable effect +Horsepower is a unit of power, as such the mass of car (should) will play a role +Tester Low has 150 HP, Med has 350, and High has 550 Test Number 5 HORSE POWER Test Number 5 HORSE POWER Test Number 5 HORSE POWER Test Number 5 HORSE POWER Test Number 5 HORSE POWER
Test Number 5 HORSE POWER
]The vehicle will run a course half the distance of Flatgrass ]times are recorded with the race editor featured with "s-cars." #run - low(150) 21:23 #run - med(350) 15:75 #run - high(550) 13:56 #run - EP2 Charger(350) 22:75 >While driving the low vehicle seemed to persist on gears longer, taking around four seconds to go from 3rd to 4th >Worth noting that the horsepower affected the acceleration curve far more than the axleratio did. >The additional test of the Charger confirmed my suspicion that the maxspeed variable does play a role, as even though it has higher gears it cant seem to get past third unless boosted }ZOUNDS }Within each vehicle script there is sound defined to play at a percent of the max-speed simulating the "gear" }changing anything about the way the speed of acceleration works (or topspeed) means these pre-defined spots no longer initiate where the "gear changes" }Need to find a way to print all this entity info to the screen while playing to truly define the changes right }Does it even use these variables? or just baked them into some static trickery? >Horsepower seems to be a more direct translation to its real world equivalence }HOLY CODE }I opened up SourceSDK and created a mod just to peek at the vehicles.h and see what parameters did what as well as other code }interesting to note that the default limit is four axles, meaning you could perhaps have a tank-like vehicle if there were a way to define additional wheel attachments. }checked the MP code and it is indeed the case that We determine which sound to play based on speed, not on gear }Also of interest "Vphysics is hardcoded so that vehicles must face down Y, instead of X like everything else" )Lets imagine it this way, horsepower controls how quickly the rpm can increase, and rpm controls how quickly the gear can increase since its automatic transmission. )Since manual isnt an option, is there any point in having the max RPM be higher than the shiftuprpm? Doesn't it always shift after hitting threshold? TEST Number 6 SHIFTING GEARS TEST Number 6 SHIFTING GEARS TEST Number 6 SHIFTING GEARS TEST Number 6 SHIFTING GEARS TEST Number 6 SHIFTING GEARS
TEST Number 6 SHIFTING GEARS
The v-scripts relevant info for tests 5 "body" { "countertorquefactor" "0" "massCenterOverride" "0 -30 12" "massoverride" "1000" // kg "maxAngularVelocity" "720" } "engine" { "horsepower" "350" // Engine Power "maxrpm" "3000" "maxspeed" "135" // mph "maxReverseSpeed" "23" // mph "autobrakeSpeedGain" "1.1" // 10% speed gain while coasting, put on the brakes after that "autobrakeSpeedFactor" "3.0" // Brake is this times the speed gain "autotransmission" "1" "axleratio" "4.56" // Some kind of traction control for the wheel ray-caster. Increases acceleration AND Torque "gear" "6" // 1st gear "gear" "3" // 2nd gear "gear" "1" // 3rd gear "gear" "0.5" // 4th gear "gear" "0.2" // 5th gear "shiftuprpm" "****" // The Tested Variable for this batch "shiftdownrpm" "300" +Since the GR are so different from each other I attempt to establish the difference shiftupRPM makes +Low is 1500, medium 2333, and high is 2900 +Same dragrace test as before #Low-17:07 #Med-15:42 #High-14:32 >All three have equivalent HP and gears but the High still edged out the competition by shifting the latest apparently ]Then modified to "gear" "5" // 1st gear "gear" "4.5" // 2nd gear "gear" "4" // 3rd gear "gear" "3.5" // 4th gear "gear" "3" // 5th gear ]Causing the race to be incompleteable on all three >The removal of gears that were more ideal for high-speeds results in the car losing control after a certain speed but acceleration was good on all three >Without knowing which gear I was actually in its hard to be sure which is the point of no return >Could be useful for larger vehicles like busses which become difficult to handle past a certain speed ]Then modified to "gear" "4.5" // 1st gear "gear" "3.2" // 2nd gear "gear" "1.3" // 3rd gear "gear" "0.7" // 4th gear "gear" "0.4" // 5th gear +Low is 2300, med 2600, high 2900 #low 15:75 #med 15:25 #high 15:06 >Its encouraging to see all three values very close, the shiftuprpm seems to have a purpose ]Then modified so the max RPM is below the shiftupRPM value by 100 for each tester #low - 14:29 #med - 14:39 #high - 14:77 >I was hoping they would all get times in the twenties since they couldn't shift, but somehow they got faster
Batch B Tests 7 and 8
TEST Number 7 REDLINE TEST Number 7 REDLINE TEST Number 7 REDLINE TEST Number 7 REDLINE TEST Number 7 REDLINE
TEST Number 7 REDLINE
The v-scripts relevant info for tests 7 "body" { "countertorquefactor" "0" "massCenterOverride" "0 -30 12" "massoverride" "1000" // kg "maxAngularVelocity" "720" } "engine" { "horsepower" "350" // Engine Power "maxrpm" "****" // The Tested Variable for this batch "maxspeed" "135" // mph "maxReverseSpeed" "23" // mph "autobrakeSpeedGain" "1.1" // 10% speed gain while coasting, put on the brakes after that "autobrakeSpeedFactor" "3.0" // Brake is this times the speed gain "autotransmission" "1" "axleratio" "4.56" // Some kind of traction control for the wheel ray-caster. Increases acceleration AND Torque "gear" "4.5" // 1st gear "gear" "3.2" // 2nd gear "gear" "1.3" // 3rd gear "gear" "0.7" // 4th gear "gear" "0.4" // 5th gear "shiftuprpm" "*(maxrpm/2)+(maxrpm/4)" // The Tested Variable for this batch "shiftdownrpm" "300" +In theory, increasing the maxRPM should have very little effect on how the car performs because the horsepower determines the rate at which it increases +Because of this I will also increase the shiftuprpm based on the maxrpm +as the previous test showed, the factor which most determines the speed is the shiftupRPM, so by increasing both we may actually lose performance. +low is 3000, med 4500, high 6000 maxrpm #low - 15:69 #med - 15:93 #high - 16:09 >as suspected the increase is relatively meaningless but may be more important with weak engines or much stronger ones ]Then modified so the Horsepower is 600 for each tester #low - 13:29 #med - 13:88 #high - 13:27 >ignoring the obviously quicker time, its clear that with a more powerful engine either the shiftuprpm or maxrpm needs to be modified ]Then modified so the Horsepower is 600 for each tester, maxRPM is 6000 for each tester, and shiftuprpm is low 4000, med 4500, and high 5000 #low - 13:91 #med - 13:30 #high - 12:83 >Back to a linear increase in times here, I think the vital stat to consider is the shiftuprpm, and just have the max be equal or higher and then to test >If manual was added the maxRPM would have some purpose, but since no shifting mechanic exists for the cars they probably forgot to just combine the two functions into one TEST Number 8 AWD TEST Number 8 AWD TEST Number 8 AWD TEST Number 8 AWD TEST Number 8 AWD
TEST Number 8 AWD
The v-scripts relevant info for tests 8 "torquefactor" for axle front and back +I never really noticed that the jeep handles differently to the charger because one is FWD and the other is RWD, but neither one is wholly FWD or RWD +Low will be .9/.1 FWD, med will be .5/.5 4WD, high will be .1/.9 RWD #Past the first blast of speed, both the FWD and RWD iterations handle about the same. Lost traction on high speed turns #The 4WD version handles extremely well at all speeds, impossilbe to lose traction at high speeds without boosting or collison. ]Now to try 1/0 and 0/1 #handles slightly different but works about the same ]Now to have the "brakefactor" be the opposite of the torque factor #no signifigant changes
End
I wanted to know more fully what every one of the parameters were doing on an engine level, or even how to display things like gear/rpm/speed using dev commands but I could find very little.

I ended up using wiremod's speedometer and scar's racing tool to glean information on speed and made maps to get friction and wheel radius effect info.

If you have data to add or more information about vehicle scripts feel free to comment below. Most of what I learned was based on an extremely small amount of data and even now there are things far to subtle to glean from iterative testing.
5 Comments
bubby Apr 26, 2024 @ 12:44am 
tjank
i leave liknice :D3
Unknown Sep 30, 2023 @ 4:32pm 
where is the link for that lovely ratrod?
Thiagozzz Apr 22, 2023 @ 2:09pm 
where can i find the sound names and state names, and if i want a vehicule with no sound, how can i do it
Mikusch'); DROP TABLE users;-- Jun 8, 2021 @ 6:35pm 
Great guide, been featuring it on my profile for a few months now. Kudos!
rtd Oct 4, 2018 @ 8:23am 
Hey, what the fuck?
Is this first useful guide about vehicle scripting in gmod\hl2?

Damn.
You've done great job, tbh.

I was trying to figure out how this shit works and what is going on with vehicle scripting in Gmod, but even valve wiki doesn't explain it.
Thanks, man.
You saved ton of my time, cuz I'm sure I'll make same thing.
Just thanks.