This entity allows you to create a player-controllable train / platform etc. that follows a path consisting of
path_tracks
. Unlike
func_trains
,
func_tracktrains
will turn to face the next
path_track
, similar to how real world trains behave.
Attributes
- Name (targetname) - Property used to identify entities.
- Render FX (renderfx) - Gives objects special render effects. Think of it as modifying whatever the Render Mode puts out. The options are as follows:
- 0 = Normal
- 1 = Slow Pulse
- 2 = Fast Pulse
- 3 = Slow Wide Pulse
- 4 = Fast Wide Pulse
- 5 = Slow Fade Away
- 6 = Fast Fade Away
- 7 = Slow Become Solid
- 8 = Fast Become Solid
- 9 = Slow Strobe
- 10 = Fast Strobe
- 11 = Faster Strobe
- 12 = Slow Flicker
- 13 = Fast Flicker
- 14 = Constant Glow
- 15 = Distort
- 16 = Hologram (Distort and Fade)
- Render Mode (rendermode) - Controls the type of rendering that is used for an object. Options are:
- 0 = Normal
- 1 = Color
- 2 = Texture
- 3 = Glow
- 4 = Solid
- 5 = Additive
- Global Entity Name (globalname) - If your train is going to cross level transitions, it'll need a global name.
- FX Amount (renderamt)
- FX Color (rendercolor)
- ZHLT Lightflags (zhlt_lightflags)
- Light Origin Target (light_origin) - Overrides the position from which the train will receive its lighting when the map compiles. Useful if the train doesn't have the correct lighting in-game. This can be used with an info_target.
- First stop Target (target) - The name of the
path_track
to start at.
- Sound (sounds) - Values:
- 0 = none
- 1 = rail 1 (
plats/ttrain1.wav
)
- 2 = rail 2 (
plats/ttrain2.wav
)
- 3 = rail 3 (
plats/ttrain3.wav
)
- 4 = rail 4 (
plats/ttrain4.wav
)
- 5 = rail 6 (
plats/ttrain6.wav
)
- 6 = rail 7 (
plats/ttrain7.wav
)
- Distance between the wheels (wheels) - This determines how the train behaves when turning corners. Generally the length of the object works here.
- Height above track (height) - This is the height above the path_track that the train will ride, based on the location of the train's origin brush.
- Initial Speed (startspeed) - The speed the train starts at, until overridden by player control or
path_track
settings.
- Speed (speed) - The maximum speed the player can make a controllable train go in units/second. The global entity speed limit is 2000.
- Damage on crush (dmg) - If train movement is blocked by the player, deal out this much damage.
- Volume (volume) - Range: 0 - 10.
- Bank angle on turns (bank) - This is the angle the train will tilt when cornering.
- Minimum Light Level (_minlight) - The minimum light level the train will have, even if its initial position in the editor is in a purely dark room. This is a very aggressive value, so even a value of 0.02 will make the train relatively bright.
Flags
- No pitch(X-rot) (1) - Enabling this will make the train rotate on the Z axis only (yaw - left and right)
- No User Control (2) - Removes the player's ability to control the train (free ride to death?... yeah!)
- Passable (8) - Makes train non-solid.
Notes
- A func_tracktrain requires an origin brush to align itself with the
path_tracks
.
- The brush model of the tracktrain must face "West" (towards -X axis, or
◀━━━
on the Yaw compass).
- Sometimes the entity might require an 180 degree turn to appear correctly in-game, instead of 90. The cause of this is unknown (possibly an engine bug?) [needs confirmation]
- The entity will pick up its lighting – static, animated, or toggled – from where its placed or from the point set in Light Origin Target. This lighting stays with the train as it moves throughout the level.
- When it spawns in the game it will automatically move to the first
path_track
and orientate itself to face the second path_track
.
- Changing the degrees in the yaw circle won't affect the direction that the
func_tracktrain
faces in-game. The degrees in the yaw circle in the path_track
don't change anything either.
- A
func_traincontrols
entity allows the player to control the train. They are not part of the func_tracktrain
and their placement only determines the area of use. They will automatically stay in that area relative to the train as it moves.
- Without this entity the train defaults to a certain area around the origin as the controllable area. To prevent user control of any kind check the No User Control (2) flag.
- You can tie CLIP brushes to the entity, which prevents player movement (i.e. to stop the player falling off the sides or the "windows" on the Black Mesa Inbound tram ride). Also useful to simplify collisions for detailed brushwork when combined with
zhlt_noclip
.
- Triggering a named train starts/stops it.
- All trains in a campaign with the same global name acts as the same train. This is used on changelevels to replace the train from the previous level with the one from the next level making the train ride appear seamless, like those in Black Mesa Inbound or On A Rail.
- This does mean you need to place the same train models with the same global name on all the levels that the train ride goes through.
Origin, wheel distance, and heading
The above shows a visualization of the relationship between origin, wheel distance (
┃ yellow line), and its impact on heading (
┋ green dashed line).
Train A to the left has its origin at the center, while Train B to the right has its origin at the back. On both trains the
distance between the wheels is set to be the length of the train.
Train A's leading wheel ended up way in front of the train by half the trains' length, resulting in the train turning too early, more skidding along the track than following it. Train B stayed on track more consistently.
I'll make a tutorial on my channel if I figure it out.
[2024-05-12] While I am a proponent of the origin at the back axle, more realistically moving trains, I can see how it is totally incompatible with track [auto]changers. Gotta have to pick your poison, I guess.
[2024-05-13] Also, a tutorial for track trains is needed.
[2024-07-10] You can control a
func_tracktrain
remotely usinggame_counter_set
entities. Value1
throttles up one notch,-1
down a notch.