Garry's Mod

Garry's Mod

Pyroland Police Cruiser [Vehicle]
Who 8 Jan, 2017 @ 12:08pm
Try this script?
Originally posted by Astatu:
Yeah, I wish there was more I could do for it, but vehicle scripting is very obtuse and undocumented as it is. What you see here is cobbled together from the small article on the Source Developer Wiki, recycled HL2 vehicle scripts, and blind experimentation. It's a right pain.

Well, I've played with car's script, and it became better.
Here the part of script, that I have changed:

{
"wheelsperaxle" "2"
"body"
{
"countertorquefactor" "1"
"massCenterOverride" "0 -0.01 0"
"massoverride" "800" // kg
"addgravity" "0.33"
}
"engine"
{
"horsepower" "350"
"maxrpm" "3000"
"maxspeed" "45" // mph
"maxReverseSpeed" "20" // 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" "1.86" // 1st gear
"gear" "1.59" // 2nd gear
"gear" "1.17" // 3rd gear
"gear" "1.0" // 4th gear
"gear" "0.84" // 5th gear
"shiftuprpm" "1500"
"shiftdownrpm" "300"

"boost"
{
// "force" "1.5" // 1.5 car body mass * gravity * inches / second ^ 2
"duration" "0.0" // 1 second of boost
"delay" "15" // 15 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" "30" // 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"
}
< >
Showing 1-2 of 2 comments
Astute  [developer] 9 Jan, 2017 @ 4:31pm 
I've tested out your script, as well as messed around with my own. I'm seeing a lot of flipping still, and I'm not sure why. Your script changes were a good idea, and it has improved the handling a little bit, but the car as a whole is still pretty unstable.

I even went so far as to do research as to why cars flip, test drive the HL2 Ep2 jalopy, and decompile a couple of the HL2 vehicles to figure out why they stick so closely to the ground. I found out that the way vehicles are handled in Source are not the same as in real life. Cars are usually bottom heavy, with the top half being very light(open air). In Source, they are one solid chunk of metal.

By all accounts, this vehicle should work, but it doesn't. It's almost as if there is something wrong with the model. I need to think this over a bit. I'll have to look into tweaking its origin of mass.
Astute  [developer] 9 Jan, 2017 @ 5:22pm 
As it turns out, the center of mass on the vehicle was set to 0, which means all of his weight was directly on the ground(rather than floating in midair supported by wheels, like a vehicle should be).
This eliminated the flipping issue. In fact, the vehicle is quite rigid now, and refuses to flip unless you force it to.

I also punched in the appropriate weight and engine values for this vehicle based on the real world specification. It should have the correct number of gear shifts and axle ratio as well.

Thanks for the script, it gave me the appropriate springboard to help track down what the issue was by using it as a comparison tool. I've added you to the description thanking your for your contribution.
< >
Showing 1-2 of 2 comments
Per page: 1530 50