func_tracktrain Last edited 2 months ago2024-02-09 04:59:56 UTC

func_tracktrain - Brush Entity

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

Flags

Notes

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.

3 Comments

Commented 9 years ago2014-11-24 15:31:52 UTC Comment #101139
Hmpf. Anyone know a trick to make func_tracktrain?
Commented 9 years ago2014-11-26 00:52:09 UTC Comment #101140
I'm experimenting with func_tracktrain at the moment.
I'll make a tutorial on my channel if I figure it out.
Commented 3 months ago2024-01-05 12:12:36 UTC Comment #105848
Some findings about func_tracktrain:
  • wheels distance is only measured forward from origin. To make the train travel as much on the path as possible, the origin needs to be located at the center of the back axle.
  • wheel distance defaults to 100.
  • target of a path_track is fired when the origin passes the path_track.
  • the position and angle is set wrt the origin point as follows:
    1. trace a line forward.
    2. if there's enough distance to the end of the current path, keep heading
    3. if wheel distance > distance to next path, subtract current distance to next path, then iterate the path forwards until the distance fits the path. the point where distance is 0 is the new heading.
    4. origin moves forward
    5. angle is adjusted to point to the heading. this will in all cases be shorter than wheel distance; the sharper the curve the more noticeable. this also means the front wheel part will always overshoot the path. but the origin is guaranteed to always be on the path.

You must log in to post a comment. You can login or register a new account.