Tutorials

Escalator



This tutorial will teach you how to create a working escalator, the "moving staircase" often seen in malls and airports. It's a relatively easy process--most of the actual brush and entity work is simple cloning. If it looks long, don't worry; it's just the way I write. I hate tutorials that don't give you enough information, so I have decided to be very descriptive and let you decide if you need all of the info or not. The only thing that is out of the ordinary is that you have to modify the FGD, which we will do first.

Step 1: Modify the FGD

If you mapped for Half-Life, you will probably remember a very common and useful entity called a func_train. We will need that entity to construct the escalator. It's still supported, but isn't in the current Half-Life 2 FGD, so we will have to put it there ourselves. Open the FGD file using Notepad (the default location is C:\Program Files\Valve\Steam\SteamApps\(user)\sourcesdk\bin\halflife2.fgd). You will see a long list of entities and their characteristic descriptions, keyvalues, and flags within Hammer. Scroll down to the bottom of the list and copy/paste the following text into halflife2.fgd:

@SolidClass base(Targetname, Origin, RenderFields) = func_train
[
	spawnflags(flags) =
	[
		8 : "Non-solid" : 0
	]
	texframeindex(integer) : "Initial Brush Frame Index" : : "Use this to set the initial frame of materials with multiple frames in the brush"
	target(target_destination) : "First path_corner"
	noise1(sound) : "Movement Sound" : : "The sound to play when the train moves."
	noise2(sound) : "Stop Sound" : : "The sound to play when the train stops moving."
	speed(float) : "Speed" : "50.000000" : "Speed at which the brush moves."
	volume(float) : "Sound volume [0.0, 10.0]" : "0.000000"
	dmg(float) : "Crush Damage" : "0.000000"
	input Toggle(void) : "Toggle movement"
	input Start(void) : "Start movement"
	input Stop(void) : "Stop movement"
	input Use(void) : "Toggle movement - has a different functionality than Toggle"
]


There is a section of the FGD devoted to other entities of this class, but I prefer to add this new entry to the end. This way I know it was manually added and can easily remove it later if I wish. You can put it somewhere else within the FGD if you want. After you have put this new entry into the FGD, close the file and save it when prompted to do so. Now we can start the construction process.

Step 2: Construct the stairs (func_train)

Open the Hammer editor and create a new map. I advise doing it this way, rather than within an existing map, because soon we are going to have a lot of entities in a relatively small space--which can be confusing if the construction area is already filled with geometry and other entities. I would also advise turning off entity names (under the View tab) to reduce clutter while we build.

The first thing you will need to do before you begin is decide how tall your escalator needs to be to get from one level to the next. This determines how many steps your escalator will have. In my example, I have constructed an escalator that can raise the player 160 units--that is, 10 steps, which are each 16 units tall. How many steps you will need will vary, but keep in mind that anything more than 16 units will probably not only look strange, but maybe make it difficult for the player to walk up if he doesn't want to wait for the escalator to raise him by itself. Also, smaller step sizes will require more steps to reach the top level, which means your escalator will get longer and longer as step size decreases.

Our first brush will be one of the steps. Create a brush that is 16 units wide, 48 units long, and 16 units high. Next we need to create an origin brush, which will tell the func_train how to orient itself as it moves. Go into the textures and type origin into the filter. A green texture with the word "ORIGIN" should appear. Select this texture and create another brush, this time 4 units wide, 52 units long, and 4 units high. The brush must be completely covered in the ORIGIN texture to work properly! Take this brush and skewer it directly through the center of the step we created. Make sure it is exactly through the center, or there will be problems later.

Step 2, Figure 1: Step alone, orgin brush alone, step and origin combined

news post image

Next, we will turn our step-and-skewer into a func_train. Select both brushes at once and click toEntity. In the Class: box, select func_train. The only keyvalues/flags you need at this point is the Speed, which should be set to 16. For a basic escalator that will start on and will not be able to be turned off, your steps don't need names. You don't want to set a movement sound, either, because if you do this for all of them you will have quite a racket--better to create an ambient_generic to handle the sounds later on.

Now that we have one step, we can make the rest. Clone this one func_train into as many steps as you will need, plus one extra. You'll see why in a bit. (If you've never used the clone tool, it's easy. Just hold shift while you drag the original object to where you want the next one to be, and it will create a copy automatically.) Place the steps so that they are sitting like a staircaise. Make sure there aren't any gaps between them, or it will ruin our illusion. Set the extra step you created off to the side for now.

Step 2, Figure 2: A series of steps and one extra

news post image

Step 3: Create the path of movement

A func_train uses path_corner entities to not only tell it where to go, but where to start off in the world. We need to create some places for our stairs to start. We could have done this part first, but it's easier to visualize where you need to put the path_corners if you can already see the steps. First, create a starting point for our first step. Select the point entity tool, then in the Objects: box, select path_corner. Create a path_corner directly in the center of the first step of our staircase. In the Object Properties, give it a name of step1. This is the only keyvalue you need to worry about right now. Using the clone method, create starting points for all of your other steps AND four extra path_corners, placed like so:

Step 3, Figure 1: Path_corners alone, path_corners with their func_trains

news post image

These extra path_corners, along with the extra func_train we created earlier, will be vital to pulling off our illusion. Take note that in the example there are fourteen in all! Ten for the steps themselves, one to the right of the top step, and three down below the first two steps. Also note that to place step13 correctly, you will have to drop your grid size down to 1 and move it from there. Make sure that the last path_corner in your set has step1 set as its next stop target. If you cloned them correctly, all of the others should have this part of their Object Properties filled out automatically.

Step 4: Tell the steps where to start

So, we have func_trains and path_corners, but we have to tell each stair where it will begin. Select the first stair in your escalator and under the Object Property keyvalue First path_corner, select step1 from the drop-down list and apply your changes. Do this for each of the other step, matching up each one with where it starts in the world--the fourth step will begin at path_corner step4, the tenth one at step10, and so on. In the example, the mysterious extra step will have a starting point of step13, which was the one path_corner we had to drop the grid size all the way down to place. Now that you know where the extra step will start, you can move it there if you want, for visualization purposes--it won't matter in-game where the func_trains begin in the world, because when the map spawns they will immediately teleport to their first path_corner.

Step 5: Create the illusion

This is the fun part, where we get to pull the wool over the eyes of the player. When we are finished, they will have no idea that we have constructed a fully-functioning escalator with only the number of steps that can be seen at any given time, plus one. If you were to place your escalator in a map right now and run it, you would see your stairs gently moving along the path we created, everything looking good until--that's right, until the steps run out! After all, there are relatively few and it takes a while for the first step to cycle around to its start point again. By tweaking some settings, we are about to change all of that.

The first thing that needs to be done is that the path_corner right before where our infamous extra step begins needs to have the flag Teleport to THIS path_corner checked. This will make the stairs cycle around to the start point faster than would otherwise be possible. Now if you ran the map, you would see a continuous flow of steps that move normally on the front side, but speed around the back. Our extra path_corners (the ones that are not part of the series of starting points) now serve a useful purpose. At the top, they allow the stairs to move into a position where they can teleport to the bottom unseen. At the bottom, they slow down the stairs before they go through the cycle again so that you can't see them teleporting into place. Also, the purpose of our extra step now makes sense. It fills in a gap while the top step moves into place to be teleported back around to the bottom.

Unfortunately, you would also notice that as the steps go around, some of them get little gaps between them. This is because the teleport movement screws up the timing of the steps a little bit. This is where we will fix that. First, we must edit the Object Properties of our extra step. It needs to have a starting speed of 17, instead of 16 like the others. This will fill in one of the gaps, since it will move a little more quickly to find its place behind the first step as it moves up. However, to keep it from eventually overtaking all of the other stairs in the escalator, we have to edit the properties of the next path_corner (the one right before the first step's starting point) to have a New Train Speed of 16. This makes the extra step return to a normal speed after it intially hurries to get into place.

The next thing we have to do is fill in the gap that emerges behind the extra step, the one from the top step getting screwed up as it teleports. To do this, we must set the top step's starting speed to 18. We also have to change its starting point to reflect a New Train Speed of 18. This will make our top step, as well as every step that passes through this path_corner, temporarily speed up to 18 units/second as it prepares to go to the teleportation area. The increase in speed will be imperceptible to the player, unlike a big gap between the steps, which would be easy to notice. Now if you run the map, assuming you placed everything correctly, you would see the steps smoothly cycling, with no gaps. Good job! We're almost done.

Step 6: Complete the illusion

These will be the final touches. First of all, a set of moving stairs alone doth not an escalator make. The steps need a texture, obviously. You will probably want some detail brushes that will make it more realistic-looking, like some guards on the sides to keep people from falling off. In the example map, all of the detail brushes are made of glass so that you can see what's going on "behind the scenes". In real life, it's very common for escalators to have glass side-guards like that.

You will also need to make sure that the player can't see where the steps come from or where they go. At the bottom, this is easy. Just take the whole escalator (and all the entities!) and place it so that the very first step starts one unit above the floor. The extra step will start almost completely in the floor, but that's not going to hurt the operation of the escalator at all. You can make the bottom of the first step start flush with the floor, but this will produce texture flickering in the steps that cycle up through the floor.

At the top of the escalator, you need a brush that will make a landing, somewhere for the steps to move that will cover up the teleportation. This is also easy. Just create a brush that starts off flush with the back side of the top step and is at least one unit taller than it. The steps will slide into place and nobody will know where they go.

And, last but not least, a sound. Place an ambient_generic somewhere near the escalator and give it a pleasant sound, like one of the elevator noises that gives the impression of smooth, steady operation. Make sure it starts on.

Step 6, Figure 1: Completed escalator with side-guard removed to show inner workings

news post image

Other things you can do

Besides looking cool and actually working, this escalator starts off pretty plain. Sound and detail brushes complete the illusion, but there is always more you can do.

If you want, you can create moving hand-rails like they have on real escalators by turning a brush into a func_conveyor and setting it to move at the same speed that the steps do. Of course, if you are using the regular Half-Life 2 textures, you will have to create one or turn an existing one into a scrolling version--otherwise your conveyor will still move things, but it won't look like it's going anywhere.

With a little tweaking, you could make an escalator that runs the other way, as they often have the up and down versions near one another in real life.

You could even set it up so that the escalator can turn on and off. All you would need to do give all of the steps the same name, and set up a button or switch with the desired settings and and Output of OnPresed, (escalator name), and Toggle.

A warning

Things can block this escalator! Occasionally something can get wedged in it somehow and will disrupt the interval of the steps and create gaps, which can only be fixed by restarting. It shouldn't happen, as long as at the top of the escalator the player has room to move away (not closed in by a low ceiling or obstacle). But if it does, you can always set the func_trains to have crush damage so that if the player or objects get caught they will be gibbed immediately. For single player, this is probably a bad idea--if I were rolling along it would annoy me to suddenly have to reload my last save because Gordon got his big toe caught in "some stupid mapper's faincy movin' staircase". But for escalators set up in multiplayer maps, it's probably important that getting stuck in it kills you right away to avoid the escalator being screwed up for everyone else in the game for the rest of the round. It's possible that you could also construct the steps so that they overlap slightly, which might prevent things from getting caught in them.

Also, I haven't tested this escalator with different-sized steps or different numbers of steps, so don't be surprised if you have to do some manual tweaking of settings in order to get everything to work just right. However, all of the basic principles should be the same no matter how tall your escalator or what size your steps are.

tharawdeal

View comments ( 10 )

Back to top