|
|
|
| |||||||||||||||||||
HL2 Trains and Complex paths
(Train and/or Elevator)
This is the 4th in a series of HL2 Train tutorials. It may also serve as a Elevator/Lift tutorial. In this project: 1) Player gets on a train. 2) Train doors close. 3) Starts forward then stops once it clears a building. 4) Begins to lower, slowly, then stops. 5) Resumes backward, slowly, and then stops once inside the building. 6) Lowers again but this time down, sub-ground level. 7) Train stops and the front door lowers to create a ramp to another Train. 8) Player walks onto second Train which starts forward and continues to loop underground.
In the rather confusing image above, from within Hammer, the numbers show the stages for both Trains. 1) Train1 starts. 2) Train1 stops then lowers. 3) Train1 stops then resumes backward. 4) Train1 stops and lowers again, then the front door becomes a ramp for the Player. 5) The Player walks across the ramp to Train2. 6-10) Train2 travels on a looping path, Train1 is gone, as is the entrance. The keys to creating this kind of effect: 1) func_tracktrain Change angles property. 2) func_tracktrain Height above the track property. 3) path_track position and Orientation type property. 4) path_track Outputs. By altering these settings you can create a well controlled Train, Lift or Elevator. Note: I’m going to cover the concepts involved in a Train like this more than the properties in this tutorial. For specific settings please download the sample file below and review the previous tutorials on HL2 Trains. The Concept. . . This type of Train was a common effect in HL1. Most everything used for this sort of Player vehicle was born in HL1. Note: There is an additional effect I wanted to incorporate into this tutorial and I’ve been bugging several of the Developers at Valve for months but haven’t gotten them to talk yet. I’ve been trying to get the HL1 legacy entity func_trackautochange working in HL2. The SDK code for it seems good and I can get it to return an error when it should but it refuses to work as it should. A feature I added to this Train, because I’ve received so many questions about things like this, is a func_rot_button parented to the func_tracktrain. The front door on the Train, which later becomes a ramp for the Player, is a func_rot_button. Remember the HL2 Coast level (Yellow striped) Road Blocks that pop up out of the road? Those are func_rot_button, a handy entity for buttons, levers or a door and it can be made to move in any direction. Connecting Trains like this can really liven up your HL2 map. Imagine how different HL1 would be if Gordon had to walk everywhere. Bringing Trains into HL2, coupled with the Buggy and Airboat, is a recipe for success. The Trains in this project are brush based, as is the Train you ride in HL2. (Open the SDK example \sourcesdk_content\hl2\mapsrc\sdk_d1_trainstation_01.vmf file and examine that Train sometime.) I didn’t create rails for these Trains because they simply serve for appearance. The rails, in your HL2 maps, can be created from props, brushes or entities like env_beam and ropes. The main difference between the two Trains in this project is their Change angles property. For the first Train Change angles is Never (fixed orientation). For the second, looping, Train its: Near path_tracks Your options are: 1) Never (fixed orientation) Purpose: Train will remain in position as it moves. 2) Near path_tracks Purpose: Train orientates itself at path_tracks. 3) Linear blend Purpose: Orientates between path_tracks. 4) Ease in/ease out Purpose: Orientates between path_tracks, Swan-like movement. You will probably always use either Fixed or Near for your Change angles. Using either of the other two settings for Trains will make them look like they’re on ice. Another important thing to consider is the length of your Train and the func_tracktrain property Distance Between the Wheels. If your Trains are short this number should be smaller, but a Train that is longer than 100 units, for example, will look odd if the Distance Between the Wheels property is set low. If you can’t picture how this makes a difference try to imagine your Train coming around a corner, think of the front and tail sections of the Train. When the number is smaller your train will whip through corners rather quickly, which is why it will look odd on a longer Train. There are also important properties on the path_tracks that you can change. 1) Select a path_track and zoom in on it in the Top 2D grid, then press Alt+Enter to open the Properties. Notice the yellow indicator line on top of it? This is the direction for that path_track. When the path_track property Orientation Type is set to Face this path_track's angles it will control the Train unless the Train is set to ignore Orientation changes. 2) The path_track property New Train Speed can be used to alter the Trains speed when it reaches that path_track. You can also use the Outputs from the path_track to change the Trains speed. 3) Branch Path can be used for Alternate paths. See 4) The Flags for each path_track have a lot of control over the Train. a) Disabled (Will be ignored.) b) Fire once (Only used one time.) c) Branch Reserve (Alternative.) d) Disable Train (Train will stop functioning.) e) Teleport to THIS path_track (Train will jump to, or start at.) Notice in the image below how the position of the path_track and its Outputs create the effect needed as the Train reaches that path_track:
That path_track is named Track2, it’s the second path_track on the initial Trains journey. These are the Outputs for Track2: OnPass, Train1, Stop, 0.00, Yes OnPass, Train1, SetSpeedReal, 20, 1.50, Yes When the Train reaches Track2 it will stop and retain its orientation. One and a half seconds later it will begin to lower at a slow speed. Depending on your Rail system this might also be a good time to play a sound. Maybe the sound of metal bars crashing as the Train stops and resumes. The other settings and properties in this project for the Trains and doors should all be simple for you to determine if you download and open the sample file below. If however you have questions please let me know. |