|
|
|
| |||||||||||||||||||
Automated TrainsThis is the next in a series of tutorials on HL2 trains. In this tutorial we’ll: 1) Build a Monorail that is fully automated. 2) Create an automated Aircraft in a 3D skybox. 3) Surround the map with endless water, for effect.
For our automated ride we’re going to lock the player into the vehicle, take the player on a one loop ride and then open the door and let the player out. The endless water is for effect; while the player is riding the Monorail the view is great. As with the first tutorial on trains this project is a mini map when it’s compiled. In the image above: 1) The player spawns on the building. 2) To the left you can see our Aircraft. 3) The water looks good enough to drink. When the player gets in the train a door will appear and lock the player inside.
View of the water, compliments of the 3D skybox.
I realize there is a lot of confusion with 3D skyboxes and that’s part of the reason I’ve used one in this project, to illustrate that they are actually very simple to create, even for more complex jobs, like our circling Aircraft. The first thing I did was use the previous trains project and delete everything we don’t need, I changed the tunnel to a small building and added a ladder. Note: The ladder used in this project is only for HL2 and HL2DM, CS:S uses a brush based ladder, simply delete this one if you use this project in CS:S, then create a ladder in it’s place. You can find help on Source ladders here. Once I had the building and ladder completed I built my new brush based train, or Monorail. Same as in the first trains project this one is a func_tracktrain. This one however does not have user controls. Note: The overhead construction and path for the train are all illusionary, not solid. They serve no purpose other than appearance. I used ropes for this; in an actual map I would have created rails.
At this point you can simply download the project file, at the bottom of this page, and learn by working with that, or continue on. . .
Our Train/Monorail Class: func_tracktrain Name: Train1 Disable Receiving Shadows: Yes (Saves on resources) Disable shadows: Yes First Stop Target: Track22 (The track where it first spawns) Max Speed: 100 (Slightly slower speeds for our Monorail) Initial Speed: 0 (Spawns stopped) Change Velocity: Linear blend Change angles: Near path_tracks Distance between the wheels: 75 Height above the track: 62 (Larger vehicle, larger number, experiment) Bank angle on turns: 0 Move Sound: ambient/levels/citadel/field_loop1.wav Start Sound: buttons/button1.wav Stop Sound: buttons/button4.wav Flags No User Control: Checked HL1 Train: Checked Is unblockable by player: Checked Inside this Monorail is a trigger_multiple. This is what senses the player and locks the door, then starts the train forward. Notice the size of this trigger, it's possible for the player to re-trigger it before the train returns. I left it this way so you can see the effect. If you walk to the back and then to the front again the Monorail will shake, again each time. For an actual map I would have made the trigger the size of the entire Monorail interior. Class: trigger_multiple Parent: Train1 Start Disabled: No Delay before reset: 30 Flags Clients: Checked Outputs: OnStartTouch, shake1, StartShake OnStartTouch, Train1, StartForward OnStartTouch, BackDoor, Enable OnStartTouch, BackDoorSound, PlaySound OnStartTouch, shake1, StopShake Note: If you’re not sure how to create Outputs or Triggers please review my tutorial on Sliding doors. Also inside the Monorail is a env_shake, to make it shake a bit when it takes off. Class: env_shake Parent: Train1 Amplitude: 9 Effect Radius: 150 Duration: 2 Frequency: 2.5 Flags In Air: Checked Physics: Checked The door on the back of the Monorail is a func_brush. Class: func_brush Name: BackDoor Parent: Train1 Disable Receiving Shadows: Yes Start Disabled: Yes Disable Shadows: Yes Solidity: Toggle Solid BSP: No Flags Ignore Player USE: Checked When the door is enabled a sound is played. Class: ambient_generic Name: BackDoorSound Sound name: ambient/machines/combine_shield_loop3.wav Volume: 6 Max Audible distance: 500 SourceEntityName: BackDoor Flags Start Silent: Checked When the Monorail makes a complete loop the last path_track stops the forward motion, stops the sound and opens the door. Class: path_track Name: Track21 Next Stop Target: Track22 (Our first path_track) Outputs: OnPass, Train1, Stop OnPass, BackDoor, Disable OnPass, BackDoorSound, StopSound Those are the makings of our Monorail. Now for the 3D skybox, and our Aircraft. First off, these aren’t that difficult to make. Don’t let them aggravate you. I created this one, without the aircraft, in less than a minute. The most difficult part of 3D skyboxes is the scale. Everything in the 3D skybox needs to be 1/16th scale. If you place a prop in there it will be 16 times larger in the game. This works for you and against you. Textures also need to be scaled, which you can do with the Face Edit tool. Texture scales of 0.20 work out fairly well. These are the steps I used to create this 3D skybox: 1) Make sure your map has a normal skybox and a light_environment. 2) Place a sky_camera in the center of your map. 3) From the main tool bar, Edit, Select All. (Your entire map is now selected.) 4) Press Ctrl+C. (To copy the entire map.) 5) Press Ctrl+V. (To paste the entire copy.) 6) In the 2D Top View Port move the copy off to any side, away from the main map. 7) Save your project at this point, in case you make a mistake. 8) Go into your new copy and delete everything that will not be in your 3D skybox. This is an important step, and there are other ways of doing it. It’s best to do this part when you first create the basic geometry in your map. For this project all I needed was the sky_camera and the light_environment. 9) Now select everything in your 3D skybox, so you can scale it. 10) Press Ctrl+M, to open the Transform tool. 11) Place a mark in Scale, to select that option. 12) In each of the three input boxes, X Y and Z, enter the number 0.0625 13) Click OK to scale your 3D skybox. 14) Now go back to the main map and delete the sky_camera. 15) You should now have two exact light_environment’s but only one sky_camera. 16) Add your map geometry to the 3D skybox and then build a normal skybox around it. The only thing I added to the actual geometry is the water brush. That’s the method I use, then I run the map and make any changes needed to the height of the sky_camera. When you adjust the height make small changes, single units at a time. Here’s a page where Valve shows how to create 3D skyboxes. You can do a lot more with your 3D skybox but for this project I simply needed something for the effect of the Aircraft and water looked better than earth. I also experimented with fog but the water looked so nice so I left fog out of it.
The Aircraft in the 3D skybox is another train. For this one I’ve created a func_tracktrain that is very tiny, only 16x16x1. Fro the Aircraft I’ve placed a prop_dynamic_override and env_sprite, both are parented to the func_tracktrain so they move with it. Class: func_tracktrain Name: skyTrain1 Disable Receiving Shadows: Yes First stop target: skyTrack2 Max speed: 40 (A lot slower, its speed will be magnified by the scale.) Initial speed: 40 (Spawn moving) Change angles: Linear blend (Less jerky) Distance between the wheels: 20 Height above the track: 0 Flags No User Control: Checked Passable: Checked Class: prop_dynamic_override Parent: skyTrain1 World Model: models/Gibs/Scanner_gib04.mdl Disable Shadows: Yes Collisions: Not Solid Class: env_sprite Name: skyLight1 Parent: skyTrain1 Render FX: Slow Strobe Render Mode: Additive Disable Receiving Shadows: Yes Framerate: 10.0 Sprite Name: materials/sprites/orangeglow1.vmt Scale: 0.04 Size of Glow: 2.0 Flags Start On: Checked There are 12 path_track’s for the Aircrafts path. Once you compile this project and run it in the game you can see that even though the Aircraft was made from a Gib, broken piece, because of the angle used and the flashing sprite it works out nicely. You can have a lot of fun with a project like this, please don’t let it frustrate you, just keep experimenting and stick with what works. UPDATE: I've added a second vmf to the file below showing how to make the Trains front glass breakable. |