DeadMeat's Tutorial Logo (by KruGer)
Quake - Lesson 3 - Func_train entities

In this lesson, I'll cover how to use the func_train entity, which allows you to make brushes the player can ride around on. As usual, you'll need a map file to use. If you have one from earlier lessons, great! If not, that's okay; you can download this file and use it.

In Quake, moving brushes other than lifts and doors are accomplished mainly with the 'func_train' entity. The entity itself is pretty easy to understand, but making the path for the train to follow is a little tricky. To get started, let's make a platform for our player to ride around the room on.

Start by drawing a 64x64 brush in the Top View, centered at (-736, 224). Assign a texture of 'MMETAL1_6' to this brush and then switch to the Side view. Make this new brush 8 units high and drag it down so that it sits on the floor. This will be our platform. This brush is pretty simplistic, but your train entity can be as complex as you want (providing it's not so complicated that it creates lag problems). If you want to see a really cool example of a moving train, see The Gondola at the Quake Lab. It's great!

Once you've got the brush drawn, go ahead and switch to the Entity Window and make this brush into a 'func_train'. Assign it a key/value pair of 'sounds' '1'. This will give it the ratchety metal sound you've come to know in Quake.

Before I show you how to make your train move, let me explain something that is a little different about trains. Once triggered, a train entity will move continuously until it hits a 'path_corner' entity that has a key/value pair of 'wait' '-1'. Once it hits this and stops, there is no way I've found to restart it again. That's why a lot of the moving platforms you see in Quake move continuously after they're activated. However, you might want to make a train that only moves to a certain point and stops without being activated again. Just keep this in mind when making your own maps.

As a train is moving, it will move in a straight line (even through walls) until it hits a 'path_corner' entity. When it hits this, it will either stop, turn, or pause. If it turns, it will go in the new direction until it finds another 'path_corner'. When it reaches the last 'path_corner' in the cycle, it will return to the starting position and begin again, unless you stop it of course. The tricky part about making the train move where you want is understanding how the 'path_corner' entity works.

When you make a train (why do I feel like doing the Loco-motion?), the platform will appear at the location of the first 'path_corner' in the chain. The location of the platform is defined by the point where the center point of the 'path_corner' intersects the lowest point of the train on each axis. In our example, this point would be X=-768, Y=192 , Z=0. In order for our platform to appear where we've drawn it, we'll need a 'path_corner' which has its center point at these coordinates. I know it sounds confusing, but it's really not.

Let's go ahead and draw our first 'path_corner'. Draw a 16x16x16 brush and make it into a 'path_corner' entity. Now make sure the brush is centered on (-768, 192) in the Top View and the bottom of the brush is sitting on -8 on the Z-axis. This will put the entity's center point where we want it. This will be the platform's starting point.

Now, copy the 'path_corner' brush and paste it back into the map. Move this new copy so that it is directly above the first, with its bottom edge sitting on 120 on the Z-axis. This will be the next position our train will travel to once it's activated. Before we link these 'path_corners' together, let's go ahead and make two more. This will give our platform a nice path to follow. Copy one of the 'path_corners' and paste it, moving it to be centered on X=-768, Y=-320, and Z=128. Paste another copy and move it to be centered on X=-768, Y=-320, and Z=0. Now our train will move up into the air, cross the room, lower to the floor and return to its starting position.

Since we have all our path defined, it's time to link it to the platform. BSP makes this easy. Start by selecting the platform brush (it might be easiest to do this in the Right View). Now move the mouse cursor over the first 'path_corner' and CTRL-Click. You should see a purple arrow pointing from the center of your platform to the center of the 'path_corner'. That means they're connected. Now move to the brush directly above the first one and CTRL-Click again. Move to each 'path-corner' and CTRL-Click until they are all connected. When you've done the fourth 'path_corner' CTRL-Click on the first one again to complete the cycle.

That's all we need to make our train run. Go ahead and compile your map and test it in Quake. When you enter the room, you'll notice that the train is already moving. Why is that do you suppose? If you're thinking it's because we don't have a trigger attached to the brush, you are right. Give yourself a gold star.

Let's add a trigger entity to our platform. That way the platform won't start moving until the player steps on it. Draw a 64x64x64 brush sitting directly on top of the platform brush. Make this new brush into a 'trigger_once' entity. Now with this new brush selected, connect it to your platform by CTRL-Clicking on the platform. That's all there is to it. Run your map in Quake again. Now the brush is stationary when you first enter the room. Step on the platform and you're magically whisked away! Here's our platform flying through the air:

Come on, come on, and do the loco-motion with me!

It's a bird! It's a plane! Well, maybe not...

Since none of the 'path_corners' have 'wait' '-1' set as a key/value pair, the train will continue moving indefinitely. Just to make sure it works right, select the last 'path_corner' in the cycle and set 'wait' '-1'. Now when Quake runs, the train will stop after one trip around the room. Like I said earlier, I don't know of any way to re-start the train after it has stopped. I think this is a limitation in the Quake engine, but if you find a way, let me know.

Well, that wraps it up. Hope it wasn't too confusing. See ya!

| Return to the Quake Tutorial List | Return to the Main Page |

This site is designed for 800x600 resolution, and is best viewed in Netscape 4.0 or above with 16bit color or higher.

BSP is the sole creation of Yahn Bernier. I am only a dedicated user, reporting news and making tutorials so Yahn can spend more time enhancing BSP.

This web page was created and is being maintained by me (DeadMeat). Unless otherwise noted, all content appearing on this site was written by me. Also, 'DeadMeat's BSP Tutorials' were created entirely by me. All unauthorized use is prohibited. (c) 1997. So there :-P