Trains

From Valve Developer Community
Jump to: navigation, search
Русский
Abstract Mapping series Discuss your thoughts—Help us develop the articles or ideas you want

Ammunition | Animals | Animated Clouds | Animated Sky | Antlions | Beams | Bushes | Cables | Color | Combat | Combine | Creatures | Doors | Dust | Elevators | Environmental Lighting | Explosions | Fire | Fog | Foliage | Glass | Grass | Headcrab | Health | Ladders | Lasers | Lighting | Moving Clouds | Music | Optimization | Outdoors | Physics | Retinal scanners | Ropes | Smoke | Sound | Special effects | Sun | Terrain | Trains | Trees | Turrets | Water | Weather | Windows | Zombie


This page is about Source train entities. Train entities move along a predetermined track, and can represent anything that moves.

Entities

Main entities

Other entities

Entities not in the FGD

Setting Up a Basic Razor Train

To create a Razortrain in Hammer, you will use a prop_dynamic to parent these models to an invisible func_tracktrain brush:

  • props_combine\combinetrain01a.mdl (engine)
  • props_combine\combine_train02a.mdl (full carriage)
  • props_combine\combine_train02b.mdl (empty carriage)

Here is an example starting area:

Trains1.png

Next create a standard block with the tools/invisible texture, this will be our actual func_tanktrain entity. Now add a prop_dynamic using the model props_combine\combinetrain01a.mdl. Visible in the pic below is the razor train engine and the small block that we have made so far.

Trains2.png

Now, we are going to give the prop_dynamic model a name, Train_1. We are also going to set the parent to "RazorTrain" - we have not made the actual func_tanktrain entity yet but we will! We are also going to size the small block that we have made to be the shape of the engine and all of the cars (when we add them). Once you have finished that, select the box model and hit Ctrl+T and set the entity type to func_tanktrain.

Trains3.png

Now change the following items in the list:

  • Name: RazorTrain
  • Max Speed: 1000 (Or whatever you want)
  • Initial Speed: 700 (Or whatever you want)
  • Move Sound: ambient/machines/razor_train_wheels_loop1.wav (Or whatever you want)
  • First Stop Target: path

You are also going to have to check the following flags as well: (I made a small change to the texture and size, just ignore that)

Trains6.png

Next we are going to make our path_tracks so go ahead and make one now. Position it right on top of the tracks and name it path. Then all you have to do after that is hold Shift and move it along the tracks - this will automatically create and link additionally path_tracks.

Next create a ambient_generic with the sound of the razor train horn and set it up to be triggered somehow. As in one of the path_tracks tell it to play the razor train sound on pass. (See Pic)

Trains4.png

Now all you have to do now is tell each path_track to go the speed you want and you are done. To add more cars, you can hold shift on your original prop_dynamic model and drag it to the position you want. Now all that is left is to change the name, leave it parented to the func_tanktrain entity, change the model and resize the block to fit the train.

Trains5.png

Now don't forget to add a player spawn and test out the map. You will also have to add a logic_auto with the following items:

Output named Target entities Via this input Parameter Delay
Io11.png OnMapSpawn RazorTrain StartForward 0.00

Our finished product:

Trainsfinal.png

Notes

  • If you want a prop to behave as a train, parent it to an invisible func_tracktrain.
  • Trains must be constructed facing east (in the Top viewport of Hammer, this is facing right). They will automatically align to the path in-game. If the train is not constructed facing east, it will not face the correct direction in-game.
  • You don't need to create each path_track by hand. Create the first one, then Shift-drag it to create another; the new one will be automatically linked from the previous one. This works even for inserting new path_tracks between existing ones.
  • For Team Fortress 2 mappers: If you wish to duplicate the trains as seen in CP Well, it is necessary to parent a trigger_hurt to a func_tracktrain, as trains will not normally hurt on touch. To get the "killed by train" icon in the killbar, the damage type must be set to freeze.

See Also