Tutorial #8: The Func_tracktrain entity |
W
A V E L E N G T H |
by HellBringer |
January 24, 1999 |
 |
 |
Yes, its the much-anticipated Tutorial #8 - This tutorial will be covering one main thing: the "Func_tracktrain". I'm going to keep the intro short (as is normal these days); but as always, feel free to email me (link at the bottom of the page) with any questions or comments. Don't be shy if something confuses you or raises any questions you want answered right away. Blue statements are the functions I want you to perform. NOTE: I AM going to assume that by now you've mastered how to perform the functions we've done in the previous tutorials.
You came here for the tutorial -so without further ado, why don't you load up Worldcraft now. All tutorials are going to assume you have the latest version, and use the default setup with a 2-button mouse - you should also have all of the proper directories and tools configured before using this tutorial. Refer to the documentation, my WC Setup guide, and my Compile FAQ for details. I will be covering individual WorldCraft commands each time we execute a new command for the first time.
As an additional note; this tutorial is the first in which is becomes VERY important that you visit the Half-Life ERC and get the latest FGD file. Install it and reconfigure WorldCraft to use the newer FGD. Older versions had the "func_traincontrols" entity left out of them (as well as some others).
Once Worldcraft has been loaded, go up to the "File" menu item and click on "open". Choose the map from tutorial number 7 (If you didn't complete Tutorial 7 you can obtain the map file here: Tutorial 7 Map file), and be sure the textures load up properly! In Half-Life, all textures are stored OUTSIDE of the map in .WAD files. These
must be loaded by the map-editor so that you can apply them to various brushes. Without
textures, your shapes and levels would be done in single colors; and who wants that??
Also, I personally like to have all of the menus and status bars turned on (you can select
which ones are displayed from the "View | Screen Elements" menu). You may not
want this if you have a small screen or are running at lower than 800x600 resolution; but
at least note this: ALL Worldcraft menus and toolbars are DOCKABLE.
So I
have mine arranged like this (Note: this screenshot was from v1.6; but I still suggest something similar to this setup) - it gives me a large main
workspace for my maps, and an organized area for referring to textures, VISgroups, and
some entity controls. Feel free to experiment around and find what's comfortable for you -
as it is important that you have an arrangement that allows you to work freely and without
frustration.
Okay, first on the list is a brief discussion of these things. With all the confusion over the func_train tutorial, I want to make it PERFECTLY clear: func_train objects are JUST MOVING PLATFORMS. The func_tracktrain entity (which this tutorial is about) is the user-controllable type; IF you include the func_traincontrols entity. Otherwise, its just an enhanced func_train entity. The other KEY difference between the two, is that the func_train uses path_corner entities; while the added features of func_tracktrain really require you to use the path_track entities for it. Alright, enough chatter... set your grid spacing to 8 units. You may also want to zoom in some with the zoom tool on the "eastern" room. Select the func_train, and hit the "ToWorld" button. Then click on the same brush again to change the selection handles (the white spots at the corners) to rotate mode. Hold down the mouse button over one of the rotation handles, and swing the brush around until the status bar reads a rotation of "135" - the wedge-shaped brush should be pointed due "WEST" (to the left) in the XY view. This is so that you can see that the train has a specific orientation; and this rotates based on the layout of the path_track entities. ALSO, here's an important KEY thing to remember: The Game assumes that your TrackTrain is ALWAYS starting out facing "WEST". So if you want it to look like it is going in the right direction, and facing "forward", you MUST make it facing this direction in WorldCraft. Switch to Brush Creation mode. Go to the texture browser and select the texture "Origin". Remember that the tracktrain rotates; and all rotating objects NEED origin brushes as part of their structure, to determine the centerpoint of rotation. Now, create our brush in the XY view, make it 32 units by 32 units. In the XZ or YZ view, make the brush 24 units tall. Then confirm the brush with the "ENTER" key. Switch to Selection mode. Grab our brush in the XY view, and move it so that the center handle (the gray "X") lines up with the center of the "eastern" or "right" edge of the wedge-shaped brush. In the XZ or YZ view, move the origin brush so that it is centered (on the Z axis) with the wedge-brush. Once the two are aligned, Select both the wedge-brush and the origin brush, and press the "ToEntity" button. Select "func_tracktrain" for the entity type. For the "name" key, put in "train1". The "First Stop Target" should be "stop1". "Height above tracks" needs to be "0" (this is technically the height above the center-point of the path_track entity); and for "bank on turns", enter "10". That last key there (the "bank" key) is a bit of an interesting and querky one. It adjusts how many degrees the train will "bank", or "roll" (like an airplane turning), when it reaches a path_track. This is good for swooping movements; but bad for realism when the object is actually supposed to be traversing a track of some kind. Also, the "bank" is reversed when the train goes backwards, so instead of banking INTO the turn, the Tracktrain tips to the OUTSIDE of the turn. I'm putting it into this example so that you can see it work; but don't expect too many places where you want to actually USE the "bank" key.
Here's a Screenshot showing this func_tracktrain all set up.
Now we're ready to change the old path_corner entities into path_track ones. In Selection mode, choose the "stop1" path_corner. Bring up the entity properties and change the entity type to "path_track". Then, delete the numbers in the "New train speed" key. Uncheck any Flags that are selected, and close the entity properties box. Repeat this for the "stop2", "stop3", and "stop4" entities. For "stop4", adjust it in the Z axis to be level with the "stop3" entity. In the XY view, move "stop4" to coordinates (0, -80). Select "stop3", and move it in the XY view to coordinates (80, -32). Select "stop2", and in the XY view move it to coordinates (80, 32). You now have a circuit of path_track entities completely set up. The reason I have you move their positions around, is because I want you to see several different angles. Tracktrains work BEST when they have to turn corners that are less than 45 degrees each. We're almost ready to compile.
Here's a Screenshot showing the path_tracks and func_tracktrain.
There's one thing that we have to do before we can test; we need to add a way for the user to control our train!! Right now, the button from the last tutorial will still activate and deactivate our train - but we want one of those speed-adjusting controls. Go to Brush creation mode. In the texture browser, get the "aaatrigger" texture. Make a block in the XY view that extends from coordinates (-64, 96) to (-48, 64). In the XZ or YZ view, the block should extend from the top of the func_tracktrain; and it should be 64 units tall. Confirm this brush, go to selection mode, and select it. Hit the "ToEntity" button, and choose the "func_traincontrols" entity. In the "Train Name" key, type "train1". The func_traincontrols entity is an invisible object. If the player is inside of the brush that defines the func_traincontrols entity, they can hit the "USE" key, and bring up the Train's Controls. There are no VISIBLE parts to this; if you want something that looks like a control panel, you need to make it out of normal brushes - for the purposes of this tutorial, however, we won't be doing that.
Compile and run your map, and test this new train! If you ride the train, you may need to move or duck to keep from blocking it in certain areas where it comes near to the ceiling or walls. NOTE: The func_tracktrain doesn't START where you had it in Worldcraft; but rather at the "First stop target". This "move" is done after the level is lighted; but before the game runs - that way the func_tracktrain can be in one area for lighting and effects; and then show up somewhere ELSE in the level. Other things of note:
- The "env_explosion" entity from Tutorial 7 is still being triggered by "stop2"
- The Tracktrain automatically takes care of rotating and pitching (titling up or down) from one corner to the next.
- Pressing the button on the wall will activate the train at full speed; or deactivate it.
I want to run through a series of small changes to the tracktrain and path_tracks, compiling and testing between them. This will allow you to see how the different settings and flags change the tracktrain's behavior. Switch to selection mode. Select the tracktrain, and bring up the entity properties window. In the "Flags" area, select "No Pitch".
Compile and run your map, and test. Note that the train will rotate between corners... but for elevation changes, it now "floats" up and down; and it doesn't "pitch".
Func_tracktrains often have branching paths, and the player must be able to "choose" which path to go on. This is done by triggering a path_track. When a path_track is triggered by some event, the "next stop target" and "branch path" keys swap. Let's try a demonstration of this. First, select the button and open up the entity properties window. change the "target" to "stop4". Give the button a health of "5", so it can be shootable. Select the "stop4" entity, and in the entity properties window, change the "branch path" to "stop3". Switch to Entity creation mode. Place a "weapon_9mmhandgun" somewhere in the room. Now, whenever the button is activated, the tracktrain will begin looping between stop3 and stop4 (remember that stop3 has a "next stop target" of "stop4"). If the button is activated again, the tracktrain will resume its normal circuit. Note that the train may have to rotate like crazy, and will look goofy when it is moving between stop3 and stop4 - but this is because we are having it loop between only two points. In a "real level", we would likely send the tracktrain off on its own branch; not just back to a previous point. The other thing to note, is that the "next stop target" key is sort of special - it seems to "stick" with the tracktrain between one path_track and the next. Thus, if you trigger the button ANY place between stop4 and stop1, the train will IMMEDIATELY head over to stop3; because by changing stop4's "next stop target", you've instantly changed the tracktrain's as well. I know this is a bit confusing, so...
Compile and run your map, and test this new setup.
Click here to continue...
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. |