Tutorial #8: The Func_tracktrain entity W A V E L E N G T H
by HellBringer January 24, 1999
Foreword:
This tutorial assumes that you have both Half-Life and Worldcraft 2.0, and are fairly proficient in the use of Worldcraft, in that you have completed the previous tutorials in this series.

WARNING: This tutorial is not for the faint of heart! The map is fairly complex; so if you're not familiar with everything that's been covered in my previous tutorials, you may be a little overwhelmed. Remember to start small and build up in complexity; it will save you a lot of frustration in the end! If you have any questions or problems as a result of this thing, definitely email me and I'll try to help clear the confusion.

This article covers how to use:
- The Func_tracktrain entity
- The Path_track entity
- The Func_traincontrols entity

 

 Continued from Page 1...

   Now you might have noticed that in the single player game, there were some times when a train would simply get to a point and STOP. You couldn't go forward, just backward (or vice-versa). This is done with the "Disabled" flag. Switch to selection mode, and choose "stop4". Bring up the entity properties window, and in the "Flags", select "Disabled".

   Compile and run your map, and test this new setup. NOTE: The tracktrain will simply refuse to go FORWARD past stop3, or BACKWARD beyond stop1. Its as if "stop4" doesn't even exist.

   There's a trick that was used in the game to simulate a runaway train, and you can reproduce it rather easily.  Switch to selection mode, and choose "stop4". Bring up the entity properties window, and in the "Flags", UNselect "Disabled". Then select "Disable train". (It really should be called "disable controls", but oh well.

   Compile and run your map, and test the "runaway". NOTE: The controls are literally removed from the game until you re-load the map. BUT, external events can still affect the train - try activating the button, for example!

   There's one last thing I want to show you; but its rather tough to describe accurately, so here goes: We've covered branching once already, but there are really TWO types of branchings: FORWARD and REVERSE. Here's an illustration to help:

      We need to be able to clue the tracktrain in to when there is a REVERSE branch. We do this in much the same way as a normal branch; but there ARE some differences... so let's give it a try. Select stop4. Bring up the entity properties window. In the "Flags", UNselect the "disable train". Select the "reverse branch" flag. In the keys, set the "branch path" to "stop3". Now, select the "stop2" entity. In its keys, change the "next stop target" to "stop4". The purpose of this last part, is so that stop3 is its own little "island" branch of track. Going FORWARD or BACKWARD normally will make the tracktrain follow this path: stop1, stop2, stop4 (or stop4, stop2, stop1 if going backward). If the button is triggered, the tracktrain will go NORMALLY forward still, but if the player makes the tracktrain move BACKWARD, the tracktrain will get to stop4, and then move off to stop3, INSTEAD of stop2. After it moves to stop3, the tracktrain's movement won't appear to make sense, as there is no "further" track to follow (which there WOULD be in a "real level"). The key thing to "get" in this is that the tracktrain is ONLY affected when moving backwards.

   Compile and run your map, and test this.

   Well, that about wraps it up for this time with the func_tracktrain entity. As you can see, there are lots of possibilities; and even some we didn't cover today. I will be releasing a "follow-up" tutorial to his that will resemble the "light" tutorial in structure. It will cover the more advanced tracktrain features, such as track-change devices (those "spinning elevator" spots when in your tram at the beginning are good examples) and more. Hope you enjoyed this; and good luck with your "model train sets"!

  As always, feel free to email me any comments, questions, or problems!

Half-Life, and the Half-Life logo are trademarks of Valve Software and Sierra Online, used with permission. All screenshots and drawings of Half-Life are (c) copyright Valve Software, 1998. All rights reserved. All original content (text and art) are (c) copyright Wavelength, 1998, and may not be reproduced without permission.