While currently in the process of my first map I wanted a main feature to be 2 trains that pass through tunnels underneath the middle point. As I am still new to Hammer I found that doing it the "Valve" way seemed too complicated for myself and although looking through previous posts game me some help in this matter, nothing was relatively definitive and easy, but through a little logical thinking and trial and error I have found a quite easy way to achieve the same effect.
(Please note, on this first draft I am currently away from Hammer and so some details may not be exact, I may miss a step or two and there are currently no screenshots. When I can get back to Hammer I will provide screenshots, double check everything and rectify any mistakes.)
Step 1: Setting your path_track's
Choose the entity tool and place one entity where you want the start of your track to be, right-click>properties and under name call it something like 'Train1_path_a' then apply. Shift-drag this path_track to wherever you want your track to end and a line should appear joining the two path_track's, go to the end path_track's properties and set it's next path_track to your start path track. Go back to your first path track, then to properties, then click the flags tab and select 'Teleport to THIS path_track', this should be the only box ticked. Your path_track's now await their accompanying train.
Step 2: Setting up your train
Spawn another entity near to your starting path_track (this is purely for organisation) and change it to a prop_dynamic, naming isn't necessary, and choose "train_enginecar" then apply. Create a nodraw brush roughly the size of the of the train and press CTRL+T, change it into a func_tracktrain, name it something such as 'Train1', set its first path track to your starting path track, in our case that's 'Train1_path_a and the set whatever speed you like, for reference, the train in well uses 1024. Go back onto properties for your prop_dynamic train and set its parent to your func_tracktrain's name, 'Train1' in our case.
Step 3: The (slightly) technical part
Spawn another entity and change it to a logic_timer, for more complicated systems you may need to name the timer and it doesn't hurt to do this even if you're not, make sure start disable is no and if you wish for random timing (as all trains in TF2, that I know of, use) then select random timing as yes, input your desired minimum and maximum interval time then select the outputs tab. Add a new output and make it so that it is Ontimer, 'Train1' Start forward. Then select your ending path_track and go to the output tab, add a new output and make it so that it is, Onpass, 'Train1', Stop.
You should now have simple train that moves at random times within your set boundaries.
The guide will now be broke up into sections as although they may be important they aren't necessarily needed.
Now for the interesting part
Trigger_hurt
Choose the trigger texture and create a box around the front of your train, this is the area which will kill you if touched. Ctrl+T and change it to a "trigger_hurt", set it's parent to the name of your func_tracktrain, which in our case is Train1, set it's damage to something high like 1000 for instant kills and change the damage type to train so that any sacrifices to the train god will be known to all (e.g. kill icon will show the train symbol )
Your train is now a train god.
Moving train sound
Spawn an entity and change it to an ambient_generic, place it near or in your train for organisations sake and go onto properties, name it something like Train1_moving_sound, set it's SourceEntityName to the name of your train, Train1 in this case and set the sound name to "Ambient.Train". Apply this and then go to your logic_timer, add a new output and make it; Ontimer, train1_moving_sound, PlaySound and apply, then go to your ending path track and add a new output, make it; OnPass, train1_moving_sound, StopSound. You now have no excuse not to move out of the way of the train god.
Prefab here: http://forums.tf2maps.net/downloads.php?do=file&id=3186 , although you should learn how to make them on your own anyway
If anyone has any suggestions or wants something specific, just ask and I'll do my best to help.
(Please note, on this first draft I am currently away from Hammer and so some details may not be exact, I may miss a step or two and there are currently no screenshots. When I can get back to Hammer I will provide screenshots, double check everything and rectify any mistakes.)
Step 1: Setting your path_track's
Choose the entity tool and place one entity where you want the start of your track to be, right-click>properties and under name call it something like 'Train1_path_a' then apply. Shift-drag this path_track to wherever you want your track to end and a line should appear joining the two path_track's, go to the end path_track's properties and set it's next path_track to your start path track. Go back to your first path track, then to properties, then click the flags tab and select 'Teleport to THIS path_track', this should be the only box ticked. Your path_track's now await their accompanying train.
Step 2: Setting up your train
Spawn another entity near to your starting path_track (this is purely for organisation) and change it to a prop_dynamic, naming isn't necessary, and choose "train_enginecar" then apply. Create a nodraw brush roughly the size of the of the train and press CTRL+T, change it into a func_tracktrain, name it something such as 'Train1', set its first path track to your starting path track, in our case that's 'Train1_path_a and the set whatever speed you like, for reference, the train in well uses 1024. Go back onto properties for your prop_dynamic train and set its parent to your func_tracktrain's name, 'Train1' in our case.
Step 3: The (slightly) technical part
Spawn another entity and change it to a logic_timer, for more complicated systems you may need to name the timer and it doesn't hurt to do this even if you're not, make sure start disable is no and if you wish for random timing (as all trains in TF2, that I know of, use) then select random timing as yes, input your desired minimum and maximum interval time then select the outputs tab. Add a new output and make it so that it is Ontimer, 'Train1' Start forward. Then select your ending path_track and go to the output tab, add a new output and make it so that it is, Onpass, 'Train1', Stop.
You should now have simple train that moves at random times within your set boundaries.
The guide will now be broke up into sections as although they may be important they aren't necessarily needed.
Now for the interesting part
Trigger_hurt
Choose the trigger texture and create a box around the front of your train, this is the area which will kill you if touched. Ctrl+T and change it to a "trigger_hurt", set it's parent to the name of your func_tracktrain, which in our case is Train1, set it's damage to something high like 1000 for instant kills and change the damage type to train so that any sacrifices to the train god will be known to all (e.g. kill icon will show the train symbol )
Your train is now a train god.
Moving train sound
Spawn an entity and change it to an ambient_generic, place it near or in your train for organisations sake and go onto properties, name it something like Train1_moving_sound, set it's SourceEntityName to the name of your train, Train1 in this case and set the sound name to "Ambient.Train". Apply this and then go to your logic_timer, add a new output and make it; Ontimer, train1_moving_sound, PlaySound and apply, then go to your ending path track and add a new output, make it; OnPass, train1_moving_sound, StopSound. You now have no excuse not to move out of the way of the train god.
Prefab here: http://forums.tf2maps.net/downloads.php?do=file&id=3186 , although you should learn how to make them on your own anyway
If anyone has any suggestions or wants something specific, just ask and I'll do my best to help.
Last edited: