Vehicle Compiling & Scripting (2 Problems)

Okay my first problem is that when players get spawned into a car I made they aren’t recognized by the server as being inside the car. They assume the view angles and stuff, so they see from inside the car and stuff, so it’s okay for them, but if I render their body it’s parented to the car but floating somewhere away from it. This does not happen with the default hl2 buggy or cars from GMod, just ones I made. Am I missing something in my .qc for this? (Note that if they simply walk up to the car and press e to hop in it works fine – only when spawning them directly into the vehicle does it get fucked.)

My other problem is with the rear-wheel suspension of my vehicles.

	// rear axle
			"radius"	"17"
			"mass"		"100"
			"damping"	"0"
			"rotdamping"	"0.0"
			"material"	"jeeptire"
			"skidmaterial"	"slidingrubbertire"
			"brakematerial" "brakingrubbertire"
			"springConstant"		"80"
			"springDamping"			"8"
			"stabilizerConstant"		"80"
			"springDampingCompression"	"9"
			"maxBodyForce"			"1200"
		"torquefactor"	"0.7"
		"brakefactor"	"0.6"

This is for one of my cars, the S197 Mustang from Flatout2. Anyway, I have absolutely no idea what any of this shit does. All I know is that if I put springConstant too low the car’s rear wheel gets sunk into the ground, but if I bump it up (here it’s 80 but on some other cars of mine it’s as high as 200) then the suspension gets all fucked up and leads to the car potentially flying all around the map. Wtf do I do about this? For this car I had to copy the suspension from a Fueled Mod car because I don’t understand this shit at all and there’s nowhere online that explains it that I could find with Google.

I was able to find a pretty good reference guide which goes over a lot of the variables in the vehicle scripts, here it is. For the spring constant try to put it around 60, it’s quite a volatile value and it can cause problems if you set it to high.

As for the player position, have you put an attachment called “vehicle_feet_passenger0” on the model? It specifies the player model position when using a vehicle, make sure you put it where the player will be sitting, just slightly above the seat.

O wow, thanks for this guide!! And yea I’ll try that feet attachment.

Hey how do I prevent the car from over-steering? Like if you’re driving and you’re going 40-ish and you make a turn, when you let go of turning the car jerks even more in the direction you were turning, so you over-steer.

Yeah that’s a problem I have a lot, there are many possible causes:

  • Front wheel mass is too high, so when you stop steering and the wheels switch back it throws the car off balance. Try setting it to 50-100.
  • Center of mass, try getting this as close to the center of the car as possible while remaining low enough to not tip the car over. Use ‘developer 2’ and ‘ent_bbox’ console commands while aiming at the car and it will show the simulation wheels and other hidden parts of the vehicle including the center of mass which is a red cross.
  • Not enough rear grip, try editing the wheel material properties.
  • Rear suspension is too stiff, try making it slightly softer.

Can you elaborate on rear grip? How would I edit the material properties? I’m assuming key value work of some sort is involved here, but what exactly will I be doing?

Here’s an excerpt from the surfaceproperties_gmow script, it’s put in scripts\surfaceproperties.

	"base"			"rubber"

	"bulletimpact"	"Rubber_Tire.BulletImpact"
	"impacthard"	"Rubber_Tire.ImpactHard"
	"impactsoft"	"Rubber_Tire.ImpactSoft"

	"strain"		"Rubber_Tire.Strain"

	"friction"		"15.0"


Friction is the important part here, set it higher if you want more grip.