Tutorial: Elevators using func_train Last edited 22 years ago2002-01-08 05:00:00 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.

This article was converted from a previous version of TWHL and may need to be reviewed

  1. The formatting may be incorrect due to differences in the WikiCode processing engine, it needs to be revised and reformatted
  2. Some information may be out of date
  3. After the article is re-formatted and updated, remove this notice and the Review Required category.
  4. Some older tutorials are no longer useful, or they duplicate information from other tutorials and entity guides. In this case, delete the page after merging any relevant information into other pages. Contact an admin to delete a page.

Download attachment

The func_train entity is most commonly used to create the elevators that you see around Half-Life. It's quite versatile, so this application is only one of the things it can be used for.

func_train vs. func_tracktrain

The main differences between func_train and func_tracktrain are that firstly, a func_tracktrainbrush orientates itself with its track, whereas a func_train doesn't, and secondly, func_tracktrain entities can be player-controllable (as in the 'On a Rail' chapter in the game), where you drive a train that can have its speed controlled. func_tracktrains are a little less versatile, but perhaps more interesting, because of these differences. There are other differences as well, such as the func_tracktrain's height above track and bank angle properties.

Setting up the Map

We're dealing with func_train in this tutorial though, so I've set up a map with two floors, where a func_train acts as a simple elevator running between them. Firstly, start up WorldCraft and get a basic room built with a second floor. Make a hole in the upper floor by carving it with a brush the same size as the elevator you plan to build. Then construct the actual elevator platform. I made it with a metal texture (one of those generic ones (type 'gen' into the Texture Browser), and put a set of brushes around it with the yellow warning stripes texture, leaving space for the guide rails at the sides. It doesn't matter where the guide rail(s) go. In fact, you don't need any at all, because they have nothing to do with the elevator entity itself. They just make it look a little more realistic in this case... Elevator platforms can also be more elaborate, with safety rails and the like. Other entites can't be grouped to the elevator though, so you can't have dynamic lights that move with the platform, or a gun turret on it or anything (there is actually a mod that allows this though). One other thing to note is that brush entites of this kind (ones that are able to move) take their lighting from the place where they start off, which is one of the fundamental realism drawbacks to games based on Quake 2's engine. It doesn't matter too much though, because it is possible to artifically add lighting. I'll get back to that later.

Basic Properties

Now you can set the properties for the func_train, such as sounds and initial speed (the speed can be modified as the train passes along its path, but this is the speed that it starts off at). Set its name to something like elev and set the first stop target to something like elev_1.

The Path

Create the path points next, by placing the point entity path_corner at two positions - one on the top floor, and one on the bottom. It is quite important to get the positioning right - the elevator platform aligns itself exactly in the middle of the points, so make sure that the little 'X' in the middle of the entity is right over the 'X' of the middle of the platform in both the top and side views. The best thing to do is to drag the platform to the positions you want it to stop at, and get the path entites in the right place that way.

Place the first path_corner entity at the point you want the elevator to begin (the bottom floor on my map) and call it elev_1. The second should be called elev_2 and should obviously go on the upper floor. The next stop target for both entities has to be the next point you want the elevator to go to. i.e. the first corner needs to have next stop set to elev_2, and the second corner needs to have it set to elev_1, so that the elevator always moves along a closed circuit. Set the wait for retrigger flags on for both. This stops the elevator at each floor and waits for a button to be pressed (or any other kind of trigger). The elevator doesn't actually need to be created at the place you want it to be when the game begins - it automatically moves into the middle of the point that is set as its first stop target. This is how you can alter the lighting - place the elevator in a closed-off room somewhere else in the map, and place lights around it, wherever you need them to be. When the game starts, the elevator will pick its lighting up from here, but will always begin, and be seen by the player, at the point you set as its first stop target. This is how you can give the elevator lighting underneath etc.

The Buttons

Now all you need is a couple of buttons. This is the trickiest bit, because the buttons can be made to act in all kinds of ways, and can do things like stop the elevator half-way, not change colour, and generally cause havoc. You actually only need one button (in fact, you don't need any - you can use any form of trigger to start the elevator, such as a trigger_multiple, that can start the elevator every time the player moves onto the platform). With two buttons, the elevator can be made to start from the bottom and top floors, so that's what we'll use here. Create them any way you like, but make sure they're both func_button entites. Set their targets to elev, and set the flag don't move on if you using a texture-based switch (the common ones). You can also assign some sound effects.

Delay before trigger and delay before reset are two properties you might want to be careful with. Delay before trigger is useful if your switch isn't right next to the platform (i.e. the player has to move onto the platform after activating the switch). Combined with a nice sound effect, it can also give a realistic 'powering-up' feel to big, heavy elevators. To set delay before reset, first play the level, and time how long it takes for the elevator to move from one point to the next, in seconds (or use maths with the speed and distance to work it out). Set the delay to just longer than this, so that you are sure the elevator has stopped before it gets reactivated. Setting the toggle flag on can cause problems, because then delay before reset is ignored, and it allows the user to stop and start the elevator at any point, which isn't a good thing in this case, but might be under other circumstances (such as for cranes).

Final Word

Well, now you should find that the elevator works perfectly. Try putting some crates nearby, putting the elevator platform into the floor so that you can slide them on, and then use the elevator to take them all upstairs (what fun!). You could also set the damage on crush property for the func_train and create a trap that kills the player (like that time in the original game when you get caught and put in that room with the sliding crushers). There is a fire on pass property for the path_corner entites, which can be used to make the elevator set off some kind of explosion or do something at a particular point in its course. Try making a complex, multi-storey civilian elevator and make the buttons on each floor call the elevator to that floor... it's pretty complex, but it can be done. Be imaginative - there is lots you can do with the func_train entity!
The finished liftThe finished lift

Comments

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