CFuncTrackTrain
Code classes:
CFuncTrackTrain
CBaseEntity
(all ents)
CFuncTrackTrain
is a code class in all Source games.
Classnames:
func_tracktrain
- A moving brush entity which follows a path created bypath_track
entities. This entity was used frequently in to make player-controlled vehicles which could move forward and backward with different speeds. (Said functionality still exists in most Source games, and is accessed by standing on the entity (or within the associatedfunc_traincontrols
) and sending+use
.)
Note: User controlling functionality not present in .
Important: Unless the Fixed Orientation flag is set, build your train so that the front of the train is facing down the X axis. (This means that the front of the train is visible in the front view, top is seen from the top view, etc.) When it spawns it will automatically rotate to face the first path_track
on the path.
Bug: The Reverse and StartBackward inputs may not function correctly if the New Train Speed keyvalue in the involved path_track
entities is set to 0. The train may fail to reverse, and be jammed in place or move in the wrong direction. To solve this issue, some or all of the path_track
s must have their New Train Speed keyvalue set to a non-zero value.
Bug: Trains stop just short of their final destination, with higher speed resulting in a larger gap. At low speeds, this is hard to notice. This bug has been fixed in and later games. To do: Compare 2013 code with ASW code.
Bug: If trains do not have the same parent as the track nodes they follow, the game may crash.
Tip: While not as advanced, the entities func_door
, func_movelinear
, and func_train
have less buggy behavior which may make them preferable.
Flags[edit | edit source]
- 1: No Pitch (X-rot) - Makes the entity's pitch never change as it moves.
- 2: No User Control - Prevents players from controlling the entity.
- 4: Forward Only (Not in FGD) - The controlling player may only move the entity forward, or stop it.
- 8: Passable - Not solid.
- 16: Fixed Orientation - Makes the brush stay in the orientation it was created in. Same effect as setting Change angles to Never.
- 128: HL1 Train - Changes how the engine processes the entity's solidity. Try setting this if players move oddly while touching the brush.
- 256: Use max speed for pitch shifting move sound - See Max pitch.
- 512: Is unblockable by player - If set, players (and other entities) will not be harmed by this entity, should they end up in a situation where they would be crushed and killed by it.
Keyvalues[edit | edit source]
- Distance Between the Wheels
(wheels)
<float>
- Used for turning and stopping. Increase the value for smoother turns.
- Height above track
(height)
<float>
- How high above the
path_track
s the train will stay. - Max Speed (units / second)
(startspeed)
<float>
- The maximum speed that this train can move. Any speeds applied to this train, such as by
path_track
s or SetSpeed inputs, will be clamped to this maximum value. - Initial Speed (units / second)
(speed)
<float>
- How much speed the train will move with the moment it spawns.
- Bank Angle on Turns
(bank)
<float>
- Alters the entity's roll by this much when it moves near
path_track
s. - Damage on Crush
(dmg)
<integer>
- The amount of damage this train does to entities that block it, per tick (damage occurs very quickly). Requires that Is unblockable by player is not checked.
- Move Sound
(MoveSound)
<sound>
- A sound that is played (and looped) while the train is moving.
- Move Ping Sound
(MovePingSound)
<sound>
- A sound that is played more frequently as the train speeds up.
- Start Sound
(StartSound)
<sound>
- A sound played when the train starts moving.
- Stop Sound
(StopSound)
<sound>
- A sound played when the train stops moving.
- Volume
(volume)
<integer>
- How loudly (from 1 to 10) sounds will play.
- Min pitch
(MoveSoundMinPitch)
<integer>
- The pitch of Move Sound as the train comes to a stop. This value is between 1 and 255, with 100 being the sound's normal pitch.
- Max pitch
(MoveSoundMaxPitch)
<integer>
- The pitch of Move Sound once the train's speed reaches 1000 units per second (or Max Speed, if Use max speed for pitch shifting move sound was checked).
- Min move sound interval
(MoveSoundMinTime)
<float>
- Minimum interval between playing the Move Ping Sound.
- Max move sound interval
(MoveSoundMaxTime)
<float>
- Maximum interval between playing the Move Ping Sound.
- Change Velocity
(velocitytype)
<choices>
- The method through which this train changes its velocity as it moves along the path.
- 0: Instant
- 1: Linear blend
- 2: Ease in/ease out
- Change angles
(orientationtype)
<choices>
- The method through which this train changes its orientation as it moves along the path.
- 0: Never (fixed orientation, same effect as setting the Fixed Orientation flag)
- 1: Near
path_track
s Bug: This setting causes the train to ignore the angles on thepath_track
s. It will simply face the direction of the motion. - 2: Linear blend
- 3: Ease in/ease out
- Manual Train Speed
(ManualSpeedChanges)
<boolean>
- To do: Seems to only cause bugs.
- Manual Accel Speed
(ManualAccelSpeed)
<float>
- How fast the entity accelerates.
- Manual Decel Speed
(ManualDecelSpeed)
<float>
- How fast the entity decelerates.
- Shadows (Not in FGD)
(vrad_brush_cast_shadows)
<choices>
- Determines if this entity will cast lightmap shadows.
- 0: No shadows
- 1: Cast shadows
- Render Mode
(rendermode)
<choices>
- A special rendering mode to use on this entity.
- Render Amount/Transparency
(renderamt)
<integer>
- Transparency amount, requires a Render Mode
(rendermode)
other than Normal. 0 is invisible, 255 is fully visible.
- Render Color (R G B)
(rendercolor)
<color255>
- Color channel filter to add to this entity's texture(s). Bug: Broken for brush entities.
- Render FX
(renderfx)
<choices>
- Preset appearance effects. Partially supported in , completely non-functional in . Bug: Sometimes functions incorrectly if changed with AddOutput, but is the only way to change effects other than making multiple versions of the object.
- Minimum Light
(_minlight)
<float>
- Minimum amount of light to hit this brush. 0 is none, 1 is "fullbright". Useful because the lightmaps will not update as the entity moves.
- Render in Fast Reflections
(drawinfastreflection)
<boolean>
(available in all games since ) - Makes the entity be rendered in reflections from water materials using
$reflectonlymarkedentities
.
Inputs[edit | edit source]
- Stop
- Stops the train.
- StartForward
- Makes the train move forward (if it can).
- StartBackward
- Makes the train move backward (if it can).
- Toggle
- If stopped, start moving. If moving, stop.
- Resume
- Resumes the train moving in the current direction after it was stopped via the Stop or Toggle input.
- Reverse
- Reverses the direction of the train.
- SetSpeed
<float>
- Sets the speed of the train, as a portion of Max Speed (0.0 to 1.0).
- SetSpeedDir
<float>
- Sets the speed of the train, as a portion of Max Speed (0.0 to 1.0). This input accepts negative values, allowing for direction reversal.
- SetSpeedReal
<float>
- Sets the speed in units per second. Must be a positive number between 0.0 and Max Speed.
- SetSpeedDirAccel
<float>
- Sets the speed of the train, as a portion of Max Speed. The train will accelerate or decelerate to that speed, as opposed to instantly changing. Negative values up to -1.0 are allowed and will reverse the train. Not available in .
- Alpha
<integer>
- Sets Render Amount/Transparency
(renderamt)
.
- Color
<color255>
- Sets the Render Color
(rendercolor)
.
- EnableDrawInFastReflection (available in all games since )
- Sets Render in Fast Reflections to true.
- DisableDrawInFastReflection (available in all games since )
- Sets Render in Fast Reflections to false.
- TeleportToPathTrack
<target_destination>
(only available in ) - Teleports the train to the designated
path_track
, and makes it fire its OnTeleport output. Thepath_track
does not have to be in the train's current path. - SetSpeedForwardModifier
<float>
(only available in ) - To do: Description.
- SetMaxSpeed
<float>
(available in all games since ) - Sets Max Speed.
- MoveToPathNode
<target_destination>
(available in all games since ) - Tells the entity to move to a specific
path_track
if it's somewhere in the train's path. - TeleportToPathNode
<target_destination>
(available in all games since ) - Tells the entity to teleport to a specific
path_track
. Unlike with MoveToPathNode, thispath_track
can be part of a different path. - LockOrientation (available in all games since )
- Forces the train to stay at its current angles.
- UnlockOrientation (available in all games since )
- Lets the train rotate as normal.
Outputs[edit | edit source]
- OnStart
- Fires when the train starts moving.
OnNext- Does not exist.
- OnNextPoint (Not in FGD)
- Fires rapidly and continuously as the train moves.
!activator
is thepath_track
being traveled to. - OnArrivedAtDestinationNode (available in all games since )
- Fires when the train arrives at a node which was specified by MoveToPathNode.