http://developer.valvesoftware.com/wiki/Npc_vehicledriver
Ever wondered what the npc_vehicledriver was or did? The name kind of explains it all. But, Chip, how is it used?
Well it works like any other npc, if you have worked with them before. This guy will control the vehicle of who's name you enter into the "Vehicle to Drive" keyvalue. He can follow a chain of path_corners you set. You could make a racing map with this!
Let us begin then!
First, using the entity tool (for those who don't know) place an npc_vehicledriver and a prop_vehicle_* (Any vehicle, jeep, airboat, jalopy, whatever!).
The vehicle driver should be a rollermine, and the vehicle a little red square. The square means it has no model set yet, so lets set one!
For the World Model keyvalue for the vehicle, select the corresponding model in the Model Viewer:
models/buggy.mdl
models/vehicle.mdl (The jalopy, for ep2)
models/airboat.mdl
Give it a name, something like vehicle_1.
Now on to the driver!
Give him a Name like vehicle_1_driver. (Organized names help if you have huge maps with tons of named entities.)
Scroll down to the Vehicle to Drive keyvalue, and put in the name of your vehicle. In our case this is vehicle_1.
See the keyvalue "Target Path Corner"? This is the first corner it goes to in a path that tells him where to drive around! Set it to pathcor_1 . It will be red until we make that entity, so do not worry.
Now on to the path!
Alright so, what is a path_corner?
It is, technically, where the npc has to go. They can be chained together to make a path! That is what we will do here.
So, place a path corner where you want the path to start. Give it a name, pathcor_1
Here you make your decision, do you want a chain to make a loop or a path, or do you want the vehicle to only go to one place?
If you want a loop, see below. If not, skip to the GREEN text below in this post which states the end of the extra section.
--------------------------------------------
For "New Stop Target", make that pathcor_2 . Again, it will be red until the entity is made.
It will look like this:
Now, in the "Top 2d View" (The top right hammer view panel) select your path_corner, and shift drag it to make a copy. There should be a line connecting them. If not, try again. Keep doing this until your path is complete.
On the last one, open up the properties menu and for "Next stop target" set that to pathcor_1 IF you want it to go back to the beginning. If you want it to end there, make it blank.
Extra section ends HERE
Now to make that car actually START around the track!
If you want to use a button, see PART ONE. If want it to start on map load, see PART TWO.
PART ONE
This assumes you know how a button works, if not, see a tutorial site mentioned in the sticky --or-- request I add it if the need is dire.
Basically, it should look like this:
That's it. Skip past PART TWO.
PART TWO
So you want it to start when the map loads?
Place a logic_auto. Open up the properties.
No need to fiddle with keyvalues with a logic_auto! The OnMapSpawn fires the output AS SOON AS THE MAP LOADS.
End Parts
Now, sprinkle about some info_node's. These are little markers that npc's use to tell where they can and can't go. See this page for perfered placement.
http://developer.valvesoftware.com/wiki/Nodegraph
Start your map! If you followed the tutorial, it should work! They are kind clumsy, and so you should give them a relatively straight path with wide turns or at least a lot of crash room!
-Chip
Ever wondered what the npc_vehicledriver was or did? The name kind of explains it all. But, Chip, how is it used?
Well it works like any other npc, if you have worked with them before. This guy will control the vehicle of who's name you enter into the "Vehicle to Drive" keyvalue. He can follow a chain of path_corners you set. You could make a racing map with this!
Let us begin then!
First, using the entity tool (for those who don't know) place an npc_vehicledriver and a prop_vehicle_* (Any vehicle, jeep, airboat, jalopy, whatever!).
The vehicle driver should be a rollermine, and the vehicle a little red square. The square means it has no model set yet, so lets set one!
For the World Model keyvalue for the vehicle, select the corresponding model in the Model Viewer:
models/buggy.mdl
models/vehicle.mdl (The jalopy, for ep2)
models/airboat.mdl
Give it a name, something like vehicle_1.
Now on to the driver!
Give him a Name like vehicle_1_driver. (Organized names help if you have huge maps with tons of named entities.)
Scroll down to the Vehicle to Drive keyvalue, and put in the name of your vehicle. In our case this is vehicle_1.
See the keyvalue "Target Path Corner"? This is the first corner it goes to in a path that tells him where to drive around! Set it to pathcor_1 . It will be red until we make that entity, so do not worry.
Now on to the path!
Alright so, what is a path_corner?
It is, technically, where the npc has to go. They can be chained together to make a path! That is what we will do here.
So, place a path corner where you want the path to start. Give it a name, pathcor_1
Here you make your decision, do you want a chain to make a loop or a path, or do you want the vehicle to only go to one place?
If you want a loop, see below. If not, skip to the GREEN text below in this post which states the end of the extra section.
--------------------------------------------
For "New Stop Target", make that pathcor_2 . Again, it will be red until the entity is made.
It will look like this:
Now, in the "Top 2d View" (The top right hammer view panel) select your path_corner, and shift drag it to make a copy. There should be a line connecting them. If not, try again. Keep doing this until your path is complete.
On the last one, open up the properties menu and for "Next stop target" set that to pathcor_1 IF you want it to go back to the beginning. If you want it to end there, make it blank.
Extra section ends HERE
Now to make that car actually START around the track!
If you want to use a button, see PART ONE. If want it to start on map load, see PART TWO.
PART ONE
This assumes you know how a button works, if not, see a tutorial site mentioned in the sticky --or-- request I add it if the need is dire.
Basically, it should look like this:
That's it. Skip past PART TWO.
PART TWO
So you want it to start when the map loads?
Place a logic_auto. Open up the properties.
No need to fiddle with keyvalues with a logic_auto! The OnMapSpawn fires the output AS SOON AS THE MAP LOADS.
End Parts
Now, sprinkle about some info_node's. These are little markers that npc's use to tell where they can and can't go. See this page for perfered placement.
http://developer.valvesoftware.com/wiki/Nodegraph
Start your map! If you followed the tutorial, it should work! They are kind clumsy, and so you should give them a relatively straight path with wide turns or at least a lot of crash room!
-Chip
Last edited by Chip on Wed Oct 15, 2008 1:32 pm; edited 1 time in total