Tutorials

CS: Source Vehicles



news post image

In this pic you can see everything that will be needed. This was my attempt at adding in drivable golf carts. This was basically my test box for setting this up. I did borrow some of the setup from several other tut sites to come up with this model. This was for CS:S and not intended for HL2 in which there are greater steps to make a fully flyable/drivable car or plane. While this did not prove out wholly for me because of some details like riding in the car and how it is controled, maybe this tut will help you with some ideas. There is a plane tut for HL2 out there on some site and I will not be going into this in any detail. This tut assumes you have a understanding of mapping and using Hammer.

You can start by adding- (this is the basics for a test box)

1. A room or box for testing/playing.
2. A car for driving about.
3. 4 Thrusters, left, rigth, back, and forth.
4. A GameUI entity.
5. A funct_button.
6. Player starts.
7. 2 logic compares, right/left, back/forth.

Build a sealed room to drive around in. Make a car, it can be simple or complex, one or many brushes. You may want to make a backing or hole for the player to stand in to keep from getting tossed out. Make sure the car stays on grid. When done place a truster front and back, perfectly aligned with the center. For turning you may need to adjust for a turning radius by sliding along the length of car for the desired effect you want. I adjusted near the front to fake turning tires. Make any kind of brush you want for a button, this will be the activtion point. If you want to try riding the car you will need to place it near the car so you can use it. Place a GameUI in where you like in the map. I would place nearer the your button for ease of editing. Do the same for 2 logic compares, just place inside the map. Place a couple of player starts. Now for the hard part, tying it all together.

Func_button-

This allows you enter the GameUI
Open the properties and set the flags to Don't move and Use activates. For some reason I had toggled checked too, but I don't remember why or if it needed

news post image

Select the Ouputs tab. Click on the Add button two times and fill out the three fields.

Add output OnIn, target gameUI, and Activate.
Add output OnOut, target gameUT, and Deactivate.

OnIn and OnOut tell the GameUI to start and stop when you use the button and exit by jumping or using again.

I added more OnOuts, deactivate, left,back,... to make sure the trusters were turning off, but you may not need them. You should not have to add or adjust any key values, since you don't want the button to
move.


The GameUI-

news post image

The GameUI is what you enter to control the car.
Select the flags you need. You should use at least use one or both methods for exiting. I used hide weapon for testing to know when I entered the GameUI.

Add 2 Outputs-

XAxis, steer, SetValueCompare.
YAxis, gas, SetValuecompare.


The Car-

news post image

Select all the brushes of your car and make a func_physbox out of it and name it in the keyvalues, name it car or something. You can play around with the other settings like to take damage to blow up or render modes, I never used so I can't tell you how this works.

The Thrusters-

news post image

Open the proprerties on each truster and give it a name, like right, left, forward, back (the names are just tags and don't not effect whether the car goes that way) Point the angles in the direction you want the car to go (they should all point out from the car to provide thrust in that direction).

Select all the trusters at once and selct the Attached Object, and select the car. With all still selected open the flags and make sure Ingore Mass is checked or the car will never move. I used all the flag but the Start On, but you may need to pick and choose for your effect. In the Keyvalues field choose the Force and fill out for each one. I used 600 for front and back and 500 for left and right.


Logic Compare

news post image

Open one of the Logic Compares. Name it gas in the Keyvalues.

Add 6 Outputs

OnEqualTo, back, Deactivate
OnEqualTo, forward, Deactivate
OnGreaterThan, back, Deactivate
OnGreaterThan, forward, Activate
OnLessThan, forward, Deactivate
OnLessThan, back, Activate

This is the setup to have the keyboard read your input for go back, forward, when nothing is press the trusters stop.

Open the other Logic compare. Name it steer in the Keyvalues.
Do the same as above but switch for left and right.


Compile and test. REMEMBER you are not driving the car simply because you can stand on it, you are actually in the GameUI. Plus you can fall out easily and the ride can be jerky. Also the car is sliding around not driving, would not recommend setting the phys_box to metal, noisy as hell. If you want a real BSP based car then you will have to the pod from HL2, which is not written into CS:S. This method only works so well for cars, so I would not hope to base a whole level on this. I tried to attach the button to the car but the car won't more and I tried to have the car use the gameUI, but it does not have the settings like the func_buttton has. If you can figure out how to be in the car and activate it then this would not be so bad. This should work for phys_rotate and phys_torque too in place of phys_thruster it you want to play with them.


Example Map

Slayera

View comments ( 31 )

Back to top