func_tracktrain Last edited 4 months ago2024-07-07 15:38:04 UTC

You are viewing an older revision of this wiki page. The current revision may be more detailed and up-to-date. Click here to see the current revision of this page.

func_tracktrain - Brush Entity

This entity allows you to create a [optionally] player-drivable 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

User posted image
User posted image

Origin, wheel distance, and heading

The video to the left (or 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.
This setup unfortunately won't work well for func_track[auto]change since track trains need to align their centers to these entities when rotating and thus the origin needs to be centered.

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 10 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.

[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 using game_counter_set entities. Value 1 throttles up one notch, -1 down a notch.

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