Driveable vehicles help.

Well, I managed to finally get a custom car in-game, and it does actually work, however, there are following problems. It’s undriveable. when I press A or D, it flies through the air like crazy and causes me to take damage. That’s pretty much my main problem already.
Pic:http://img705.imageshack.us/img705/8338/2011113000007.th.jpg
It can hardly drive forward or backward.
It also spawns in the ground and I can’t pull it up, I have to spawn it against a wall instead.
Pic:http://img607.imageshack.us/img607/5045/2011113000001.th.jpg
The animations don’t work correctly. When I turn left, it doesn’t play the turn left animation for the wheels.
It turns left when I turn right and vice versa.
The collision model is pointing away 90 degrees on some animations
Pic:http://img207.imageshack.us/img207/2011/41981744.th.jpg
But yeah, my main problem is it’s not driveable at all. I really don’t have a clue how vehicles work in source, so, if anyone could help me out in any way, that would be most kind.
Before I forget, here is my .qc file, come to think of it, I now assume my mistake’ll be here somewhere:



$cd "C:\Users\Jackson\Documents\car\dirt3cars	est	est2"
$modelname "dirt3test.mdl"
$model "Body" "Car_Ref.smd"
$poseparameter vehicle_guage 0.00 1.00
$poseparameter vehicle_steer -1.00 1.00
$poseparameter vehicle_wheel_fl_height 0.00 1.00
$poseparameter vehicle_wheel_fr_height 0.00 1.00
$poseparameter vehicle_wheel_rl_height 0.00 1.00
$poseparameter vehicle_wheel_rr_height 0.00 1.00
$poseparameter vehicle_wheel_fl_spin -180.00 180.00 360.00
$poseparameter vehicle_wheel_fr_spin -180.00 180.00 360.00
$poseparameter vehicle_wheel_rl_spin -180.00 180.00 360.00
$poseparameter vehicle_wheel_rr_spin -180.00 180.00 360.00
$cdmaterials "models\dirt_3\ford_fiesta\"
$hboxset "default"
$hbox 0 "Rig_Buggy.Frame" -37.848  -10.910  -100.443  38.689  44.098  96.956
$hbox 0 "Rig_Buggy.Steer_Wheel" -6.868  -1.185  -6.556  6.808  1.064  7.347
$hbox 0 "Rig_Buggy.Wheel_FR_Rotate" -0.393  -13.903  -13.840  6.072  13.897  13.960
$hbox 0 "Rig_Buggy.Wheel_FL_Rotate" -0.408  -13.897  -13.840  6.058  13.902  13.960
$hbox 0 "Rig_Buggy.Wheel_RR" 0.000  -13.845  -13.840  7.807  13.955  13.960
$hbox 0 "Rig_Buggy.Wheel_RL" 0.000  -13.955  -13.840  7.793  13.845  13.960
$attachment "wheel_fl" "Rig_Buggy.Wheel_FL_Rotate" 0.00 0.00 0.00 rotate -0.00 0.00 0.00
$attachment "wheel_fr" "Rig_Buggy.Wheel_FR_Rotate" 0.00 0.00 0.00 rotate -0.00 0.00 0.00
$attachment "wheel_rl" "Rig_Buggy.Wheel_RL" 0.00 0.00 0.00 rotate -0.00 0.00 0.00
$attachment "wheel_rr" "Rig_Buggy.Wheel_RR" 0.00 0.00 0.00 rotate -0.00 0.00 0.00
//$attachment "headlightl" "Rig_Buggy.Frame" 96.00 25.50 30.53 rotate -0.00 -15.00 0.00
//$attachment "headlightr" "Rig_Buggy.Frame" 96.00 25.50 -30.90 rotate -0.00 -15.00 0.00
$attachment "vehicle_driver_eyes" "Rig_Buggy.view" 5.00 0.00 -6.00 rotate 0.00 0.00 0.00
$attachment "vehicle_feet_passenger0" "Rig_Buggy.view" 0.00 -0.00 -32.00 rotate 0.00 0.00 0.00
$attachment "vehicle_engine" "Rig_Buggy.Frame" 0.00 0.00 -40.00 rotate -0.00 0.00 0.00
$attachment "exit1" "Rig_Buggy.Frame" 60.00 23.00 28.00 rotate -90.00 -90.00 0.00
$attachment "enter1" "Rig_Buggy.Frame" 60.00 23.00 10.00 rotate -0.00 180.00 90.00
//$attachment "beam_damage" "Rig_Buggy.Frame" 17.00 20.00 49.00 rotate -0.00 0.00 0.00
$surfaceprop "metal"
$keyvalues  { vehicle_exit { "exit1" "upright"  } } 
$illumposition 0.034 -1.744 26.522
$sequence idle "idle" ACT_IDLE 1 fps 30.00
$sequence turn "turn" fps 30.00
$sequence suspension "suspension" fps 30.00
$sequence spin "spin" fps 30.00
$animation mdldecompiler_delta.smd "mdldecompiler_delta.smd" fps 30
$animation turn_left "turn_left" fps 30.000000 subtract mdldecompiler_delta.smd 0

$animation turn_right "turn_right" fps 30.000000 subtract mdldecompiler_delta.smd 0

$sequence turning "turn_left" fps 30.00 {
  blendwidth 2
  blend vehicle_steer -1.000000 1.000000
  delta
  autoplay
 turn_right
}
$animation wheel_fr_low "wheel_fr_low" fps 30.000000 subtract mdldecompiler_delta.smd 0

$animation wheel_fr_high "wheel_fr_high" fps 30.000000 subtract mdldecompiler_delta.smd 0

$sequence wheel_fr_suspension "wheel_fr_low" fps 30.00 {
  blendwidth 2
  blend vehicle_wheel_fr_height 0.000000 1.000000
  delta
  autoplay
 wheel_fr_high
}
$animation wheel_fr_spin0 "wheel_fr_spin0" fps 30.000000 subtract mdldecompiler_delta.smd 0

$animation wheel_fr_spin120 "wheel_fr_spin120" fps 30.000000 subtract mdldecompiler_delta.smd 0

$animation wheel_fr_spin240 "wheel_fr_spin240" fps 30.000000 subtract mdldecompiler_delta.smd 0

$sequence wheel_fr_spin "wheel_fr_spin0" fps 30.00 {
  blendwidth 4
  blend vehicle_wheel_fr_spin -180.000000 180.000000
  delta
  autoplay
 wheel_fr_spin120 wheel_fr_spin240 wheel_fr_spin0
}
$animation wheel_fl_low "wheel_fl_low" fps 30.000000 subtract mdldecompiler_delta.smd 0

$animation wheel_fl_high "wheel_fl_high" fps 30.000000 subtract mdldecompiler_delta.smd 0

$sequence wheel_fl_suspension "wheel_fl_low" fps 30.00 {
  blendwidth 2
  blend vehicle_wheel_fl_height 0.000000 1.000000
  delta
  autoplay
 wheel_fl_high
}
$animation wheel_fl_spin0 "wheel_fl_spin0" fps 30.000000 subtract mdldecompiler_delta.smd 0

$animation wheel_fl_spin120 "wheel_fl_spin120" fps 30.000000 subtract mdldecompiler_delta.smd 0

$animation wheel_fl_spin240 "wheel_fl_spin240" fps 30.000000 subtract mdldecompiler_delta.smd 0

$sequence wheel_fl_spin "wheel_fl_spin0" fps 30.00 {
  blendwidth 4
  blend vehicle_wheel_fl_spin -180.000000 180.000000
  delta
  autoplay
 wheel_fl_spin120 wheel_fl_spin240 wheel_fl_spin0
}
$animation wheel_rr_low "wheel_rr_low" fps 30.000000 subtract mdldecompiler_delta.smd 0

$animation wheel_rr_high "wheel_rr_high" fps 30.000000 subtract mdldecompiler_delta.smd 0

$sequence wheel_rr_suspension "wheel_rr_low" fps 30.00 {
  blendwidth 2
  blend vehicle_wheel_rr_height 0.000000 1.000000
  delta
  autoplay
 wheel_rr_high
}
$animation wheel_rr_spin0 "wheel_rr_spin0" fps 30.000000 subtract mdldecompiler_delta.smd 0

$animation wheel_rr_spin120 "wheel_rr_spin120" fps 30.000000 subtract mdldecompiler_delta.smd 0

$animation wheel_rr_spin240 "wheel_rr_spin240" fps 30.000000 subtract mdldecompiler_delta.smd 0

$sequence wheel_rr_spin "wheel_rr_spin0" fps 30.00 {
  blendwidth 4
  blend vehicle_wheel_rr_spin -180.000000 180.000000
  delta
  autoplay
 wheel_rr_spin120 wheel_rr_spin240 wheel_rr_spin0
}
$animation wheel_rl_low "wheel_rl_low" fps 30.000000 subtract mdldecompiler_delta.smd 0

$animation wheel_rl_high "wheel_rl_high" fps 30.000000 subtract mdldecompiler_delta.smd 0

$sequence wheel_rl_suspension "wheel_rl_low" fps 30.00 {
  blendwidth 2
  blend vehicle_wheel_rl_height 0.000000 1.000000
  delta
  autoplay
 wheel_rl_high
}
$animation wheel_rl_spin0 "wheel_rl_spin0" fps 30.000000 subtract mdldecompiler_delta.smd 0

$animation wheel_rl_spin120 "wheel_rl_spin120" fps 30.000000 subtract mdldecompiler_delta.smd 0

$animation wheel_rl_spin240 "wheel_rl_spin240" fps 30.000000 subtract mdldecompiler_delta.smd 0

$sequence wheel_rl_spin "wheel_rl_spin0" fps 30.00 {
  blendwidth 4
  blend vehicle_wheel_rl_spin -180.000000 180.000000
  delta
  autoplay
 wheel_rl_spin120 wheel_rl_spin240 wheel_rl_spin0
}
$collisionmodel "phymodel.smd" {

	$concave
	$mass 1360
	$inertia 1.00
	$damping 0.00
	$rotdamping 0.00
}


Not sure exactly because Im new to this too but try this:
$origin 0 0 0 90 (or some other rotation: 180, -90 if 90 doesnt work)
Sometimes if car is wrongly rotated it tries to move to the side instead of forward and this results in weird movement as wheels cant move to the side.

Also, it is important that you fix the collisionmodel, it affects driving ability, if it blocks the wheels the car cant move, or if its lower than wheels.

If I remember anyting else ill add. Again, these are just guesses, backup before attempting.

Did you make animations and rig yourself? Have you followed the instructions on Valve developer community? Maybe wheels are turning in wrong direction because you switched sides in steer animation.

And, it is wise when you are positioning the car in editor that you make it so wheel’s tips (spot where they are touching the ground) is at heght 0 (z axis value). Otherwise, my experience is that when you spawn it it spawns a little under ground (or above).

Goddamn I can’t test it right now because of the client.dll error I’m getting, should have gone in offline mode or something.
Anyhow I don’t know exactly if the collision model is causing this weird flying around, I can’t tell because I can’t visualize the actual wheels that drive the vehicle, so I don’t know if the collision model is interfering with that. The console command from the valve wiki didn’t work in gmod. I backed up everything one time. Also I did make everyone of the animations manually and applied the skin modifier and the weighting of the mesh for the bones myself. The bones I left mostly unchanged, save for moving the rear wheels and the steering wheel to match my custom model. The first time I followed the tutorial from the valve wiki it caused my car to crash gmod. That’s why I though about decompiling other vehicles. The model itself that MY model is based off is not the buggy from hl2 decompiled, it’s just another drivable vehicle I found on garrysmod.org I decompiled which apparently used the valve bones, I suppose. That vehicle worked fine. It didn’t work fine anymore after I recompiled it, though that doesn’t matter now because every drivable vehicle from garrysmod.org I recompiled didn’t work anymore after that. I hope I didn’t babble shit and that this all is actually useful information.

Even if collision model isnt causing it you will have to fix it before it will be fully functional, at least youl know it isnt causing it if you fix it right away. One tip: for quick collision model (not optimised if mesh has high polycount, but good for testing) take reference into milkshape, delete everything but carrosserie and then export it as phymodel.smd. That way guistudiomdl will create its own collision model based on carroserie mesh’s shape.

To see wheels (or at least how engine sees them):
developer 2
ent_bbox

I havent been able to recompile a vehicle back too, so I created my own rig.

Calubri, a number of issues may be happening here. First did you spawn the car with a vehicle script? Secondly, as for the rotation issue, show us a screenshot of HLMV with the physics box showing. Right before you take the screenshot click on Options -> Center View then take the screenshot. It might be the car facing the wrong way, not the physics box.

Also, the decompiler isn’t that great. Sometimes it can’t decompile complex models properly such that they would function if you try to compile them immediately after decompiling. This applies to every car I’ve ever tried to decompile.

I spawned the car using a lua file, which uses the jalopy(ep2 jeep) vehicle script.




local Category = "Ford Fiesta"

local V = { 	
				// Required information
				Name = "Ford Fiesta", 
				Class = "prop_vehicle_jeep",
				Category = Category,

				// Optional information
				Author = "Codemasters",
				Information = "ffr",
				Model = "models/dirt3test.mdl",
				
				KeyValues = {
								vehiclescript	=	"scripts/vehicles/jalopy.txt"
							}
			}

list.Set( "Vehicles", "ford_fiesta_open_rally_bracket", V )



Here is a screenshot with the view centered:http://img684.imageshack.us/img684/6369/screenexo.th.jpg

Looks like the car is rotated the wrong way. It needs to be facing the right. There is a rotate command for the .qc file I think u put it onto the idle .smd but I am not sure. I can check for you in a few hours when I get home.

Also you will want to make your own script… I doubt the jalopy has the exact same tire size as your Fiesta.

Thanks, I really appreciate that. For your information, I tried what jinx786 said about $origin in the .qc, I made 4 seperate model files each with the rotation changed by 90 degrees and everyone of them drove sidewards somehow.
Here is how I placed the numbers after origin, I hope I was correct with that:



1st model: $origin 0 0 0 0
2nd model: $origin 0 0 0 90
3rd model: $origin 0 0 0 -90
4th model: $origin 0 0 0 180

I strongly suggest that you dont make collision for the part in front of the wheel that is lower than middle of the wheel as its too low and will make movement dificult. Actually, everything below the red line will make trouble as suspension has to work too, so dont make collision lower than this. You wont see that collision is missing down here anyway.

http://shrani.si/f/3o/nj/2a6jqCEZ/printscreen-0.png

I know its supposed to be low but I dont think game engine cares about that.

About the rig, ill try to make it as soon as I can.

Okay, found it. Make your idle sequence look something like this:


$sequence idle "idle" ACT_IDLE 1 fps 30.00 rotate 90

If 90 doesn’t work try 270.

I don’t think the origin trick will work here, but I might be wrong.

YESSSS It works! Thaaaaaank you, I’m one step closer now to this little project I’m planning to complete.

And of course thank you too Jinx786, I’m eagerly awaiting this rig you mentioned!

SOME very minor problems still remain though, if you guys’d help me out yet again that would be fantastic.

Ok this is the very minor problem I mentioned. My wheels aren’t spinning correctly. I looked through the animation files of the decompiled vehicle and what I get is wheel_fl_spin0 + one file with spin120 + one file spin240 and that for every wheel. So I think I have to spin the wheels accordingly for the animations to work, and so I did. However when in-game, it all looks like this: http://www.youtube.com/watch?v=i3_eBcI84F0
… What do I do in that case?

Exactly this happened to me when I decompiled and recompiled buggy to change the dashboard :S

Thats one of the reasons why I started using custom rigs: http://www.youtube.com/watch?v=ZCYKKVTnAuY&feature=player_detailpage
I had only one problem with my rigs so far: I cant make suspension go directly up and down as 3ds max doesnt allow moving when a bone is connected to another bone, thats not such a big problem with cars, but it would be a problem with jeeps and trucks. I can, ofcourse, leave the bones disconnected but I am yet to see if there are any undesirable consequences.

And sorry I didnt make the rig yet, if I didnt have two partial exams next week I would have done it two days ago already.

This wheels error smells like dead frames, check in model viewer if thats true.

There are no dead frames, everying is smooth in hlmv sadly enough. But if you didn’t use a decompiled vehicle and build another one using this as base, you must have gotten some knowledge from somewhere, no?

There is very little material on that, I had to collect any piece of info I found, from VALVe Developer community, from forums here, asking members who already knew how to do this, and, ofcourse, by trying many times. Luckily I already had knowledge of 3ds max needed from before.

Needless to say learning about it was pain in the neck (must admit I still have to learn the scripting part better). Good people to ask are: TheDanishMaster, MasterChris, fremmmannn

Thanks I’ll keep that in mind, I hope one of them is active, though it seems they are anyhow.

Fremmann is more about scripting part while the other two are more for model part. Also, Sgt Sgt and Sakarias88 are working on cars.

I also wanted to say dead frames, but if it animates properly in HLMV then it might be a pose parameter issue that I have encountered. I don’t have a fix for it though. :frowning:

Try to add “wrap” instead of 360 in these lines:
$poseparameter vehicle_wheel_fl_spin -180.00 180.00 360.00
$poseparameter vehicle_wheel_fr_spin -180.00 180.00 360.00
$poseparameter vehicle_wheel_rl_spin -180.00 180.00 360.00
$poseparameter vehicle_wheel_rr_spin -180.00 180.00 360.00
Should look like this:
$poseparameter vehicle_wheel_fl_spin -180.00 180.00 wrap
$poseparameter vehicle_wheel_fr_spin -180.00 180.00 wrap
$poseparameter vehicle_wheel_rl_spin -180.00 180.00 wrap
$poseparameter vehicle_wheel_rr_spin -180.00 180.00 wrap

PS: I also strongly recommend do not use decompilled vehicles as examples. Mdldecompiller is always messing things up, and only confusing people because it working like shit. Use example content from Source SDK instead (sourcesdk_content folder) - There all clear and intelligible, with remarks in qc and another useful infomation.

Annnnnnnnnnnnd it works! Yes! Thanks a ton, dude.