Tutorial 10: Func_tank - Making a Controllable Turret | W A V E L E N G T H |
![]() |
by AK-47 | June 1, 1999 |
![]() |
|
|
![]() |
Greetings, and welcome to the func_tank tutorial. You could probably imagine that I get many questions concerning creating controllable turrets. Hopefuly this tutorial will answer all of those questions. Func_tank, I must admit, is pretty easy to use, although it is a little confusing at first glance. However, by the time you complete this tutorial you will be able to make controllable turrets with the greatest of ease. To get the most out of this tutorial, I suggest going along with me in the construction of our very own turret. Make note that every action I want you to perform is colored blue.
Our first step of course is to open Worldcraft. Make sure that you have the latest .FGD entity file from either http://halflife.gamedesign.net, or right here in the Wavelength Levels Dept. Also make sure that you have Worldcraft 2.1... although turrets work with WC 2.0, it's always best to have the most recent version of programs that you are using. Alright, now that everything is in order, create a new map file. The first thing that you have to do when making a turret is to actually create the whole turret out of brushes first. I suggest that your grid size in Worldcraft is set to 8. If you'd like to see how I have WC set up, click here. You may notice I don't have the VISGroups box in view; I like to keep it deactivated unless I need it so it doesn't clutter up my workspace.
For this tutorial I am going to keep our turret as simple as possible. By that I mean VERY simple :-) We will construct our turret out of simple blocks. Of course, when actually building a turret for your level, you will surely want to put alot more detail into it. Ok, lets start off with a room for our turret. Create a block in the top (XY) view that is 768x768. In either the front (XZ) or side (YZ) view, adjust it so that it is 384 units high. Hit Enter. You might want to adjust the position of the block in the views so that the X at the center of the block is aligned with the center of the map. This is only for neatnes. Good, now make sure our room is selected, right click on it and choose 'Hollow' from the list. Enter '8' in the box that pops up.
Click here if you want to see how our map should look so far.
You can go ahead and texture our room however you want... I'm simply applying the texture crete3_wall01 to the entire thing.
Now that we have our room set up, lets start on our turret. To make it easier to see, and so nothing gets in the way, we shall construct the turret outside of the room. Scroll all of the views over so that you have a blank area to work in. Good, now lets make the base of our turret. In the top view, create a new block that spans 96 units by 96 units. In the front or side view, resize the block so that it is 8 units high. Hit Enter.
This is how it should look right now.
Lets apply a new texture to the base. I chose outboxd. You can align it all pretty if you want, but remember this is just a tutorial to teach you how to make a turret, not beautify it :-)
Moving on we get to the body of the turret. In the top view, create a new block that is 16x16 units. Center it right on top of the 'X' marked at the center of the turret base. In the front view, move the body of the turret up so the bottom of it is flush with the base of the turret. Using the top center white block that marks the selection of the turret body, stretch the body upwards so that it measures 80 units tall. Finally, hit Enter. You can now texture the body if you want to... I textured it with crete3_wall01b just so that it would stand out as being seperate from the base. (Remember, we aren't going for looks here :-)
Your turret should now look like this.
All's good so far... now we get to the top of the turret. Create a new block in the top view that measures 64x40. Move it so it's center is aligned with the center of the body. On the front view move our new block so that it's bottom is flush with the top of the turret body. Then use the top center white block to stretch it upwards so it measures 24 units tall.
Good, now our turret should look like this.
Almost done, all that's left is to add a barrel to our turret. Anywhere in the top view, make a block that is 64x8. Move the new block so that it's left side is flush with the center right side of the turret top. Resize our new block (the barrel) in the side view so that it measures 8 units tall. Now (also in the top view) move the barrel so that it's left side is flush and centered with the center right side of the top of the turret. That might have confused you a tad, so look at this image to see how it should look so far.
Well, now the actual construction of the turret itself is done, but there's still some stuff to add. From now on, I'm going to refer to the different parts of the turret by name... the bottom will be the base, the center will be the stand, the top large block will be the body, and the long block extending from the body will be, of course, the barrel. Every turret needs an origin brush. In case you don't know, an origin brush acts as the center location for any rotating entity. It tells Half-Life what point the entity is rotating around. That means that our func_tank is gonna need an origin brush since it's going to rotate around. An origin brush is just a normal block with the 'origin' texture covering every side, much like a clip brush. Remember that the CENTER of the the origin brush sets the point where the turret will rotate. Open the texture browser and type 'origin' in the filter. Double-click on any 'origin' texture that shows up. Now, make a new brush in the top view, anywhere you want. Size it so that it is 32x32. In the front view, resize it so that it is 48 units tall. Now you can push enter to create the block. Now comes the hard part; placing it in the right location. You're going to have to move it so that the X that represents the center of the origin brush is right where the turret body and stand meet. Make sure this is the case for each view. Zooming in can help alot...
Take a gander at this image to see how it should look.
The 2D views, as you can see, are zoomed in, and the origin brush is selected so it stands out. Now, why did we place the origin where we did? Well, since we are going to want only the turret body and barrel to move, I put it so it's center was at the location where a turret would normally rotate; right where the body and stand meet.
Hopefully you're still with me so far, but don't fret... now we get to the fun part; actually making the entities! Alright, now select the body, the barrel, and the origin brush. Remember, to select more than one object hold down CTRL and click on each of the objects once in the 3D view. Good, now click the toEntity button. (Make sure ONLY the body, the barrel, and the origin brush are selected.) From the list of entities that pops up, choose 'func_tank'. This brings me to an important rule that you MUST follow if your turret is to function properly... always build your turret facing RIGHT in the top view, and then adjust the direction it will be facing when the game starts by setting the direction with the 'compass' tool (angle key) in the turret's properties. Since this is just an example turret, we can leave the compass heading at 0. Now, I'll help walk you through each of the keys we'll have to set up:
We are very close to finishing now! Two things remain to be completed; we have to add our ambient_generic entity, and put in our func_tankcontrols. Right now, click on the Worldcraft entity tool (the lightbulb). From the entity list choose 'ambient_generic'. Click once anywhere in the top view to place that entity in the level. Remember that you still have to press enter to create it, so do that now. Make sure the ambient_generic entity is selected, and move it so that it is directly over the center of the turret body. In the front view, make sure it is about 32 units above the center of the turret body.
Click here to see exactly where to place the ambient_generic.
Note that the small purple box is the entity. In case you don't know, all ambient_generic does is play whatever sound you specify. Right click on the ambient_generic entity, and select 'Properties'. Since this tutorial isn't about ambient_generic, I'm just going to quickly walk you through what to enter for the keys:
Under the 'Flags' tab, make sure Medium radius, Start silent, and Is NOT looped are all checked. Leave the others unchecked. Close the properties box for our ambient_generic.
Excellent, we now have our gunfire sound that will play when the turret is fired. Now, you might be wondering how you can tell Half-Life where the player has to be standing to control the turret (by pushing the USE key). This is controlled through the func_tankcontrols entity. This is a pretty simple enity to use. It works just like any other func_* trigger; you must attach it to a solid. In this case, imagine that the func_tankcontrolls has a control panel on each side. The player can't be standing inside a control panel, but he can use it by standing right next to it and manipulating it. This is how func_tankcontrols works. Instead of actually defining an area where the player must stand, it defines an invisible panel that has the controls for the turret on it. Before starting on the block, open the texture viewer, and type 'trigger' in the filter. Double-click on any trigger texture that shows up. Anywhere in the top view, make a new block that measures 8x96. In the front view, adjust it so that it measures 112 units tall. Now, move our new block so that it is aligned right next to the base of the turret in the top view, and so that it is on the same level vertically with the base in the side view. Now press enter.
Click here to see what I mean.
(I have the new block selected.) Good, now make sure our new block is selected, and hit the toEntity button. From the entity list, choose func_tankcontrols. If func_tankcontrols is not there, then you don't have the newest .FGD file. Download the newest one from the Files page. As you can see, there is only one key we have to worry about with the func_tankcontrols entity; 'Tank entity name'. If you can remember, we named our func_tank 'turret', so enter turret in the 'Tank entity name' key.
Hooray! Our turret is finished! One thing remains to be done; we must move our turret into the room that we made. Do do this, simply use the arrow tool and drag a selection block around the whole turret in the top view, and push enter. (Unless you have auto select on, in which case it selects it automatically without you pushing enter.) Now, simply drag our turret into our room. Make sure the turret base is flush with the floor.
Check out this picture to see our turret inside the room.
To make the finishing touches on our level, we have to add an info_player_start and a light entity. Using the entity tool, place an info_player start in the room anywhere you want, as long as it's not too close to the turret. Then create a light entity right in the center of the room both vertically and horizontally. Right clink on it and check it's properties once, just to make sure everything is set alright. The brightness should be 200. Alright! Our map is complete!
Click here to see how the completed map should look.
To see our turret in action, compile the map. You should be standing in the room we made with the turret sitting there calmly. It's time to liven it up a little. Stand right behind the turret, and push the USE key. The turret should aim where you look, and fire when you shoot :-) If the turret doesn't make any noise, doesn't shoot at the right place, or the flames aren't showing up at the end of the turret, go back in the tutorial to make sure you set up the ambient_generic and func_tank correctly. However, if it does work, congratulations! You are a func_tank master! :-)
Well, that just about wraps up this tutorial. Hopefully you learned alot from this. Let me just mention a few func_tank notes:
-- Most of the time, you're going to want to cover your func_tank with a clip brush. This is so that people don't block the turret. You'll see a clip brush over almost every prefab turret. I didn't explain how to do that in this tutorial because it would take too long to explain what is really a simple process. If you're not sure what a clip brush is, read Hellbringer's clip brush tutorial back in the Tutorial section.
-- You might notice in your map that the turret is a little out of proportion (large) compared to the player. I made everything in this tutorial a bit larger than it normally should be just so that it would be easier for you to work with it. When you actually get to making your own map, you'll definately want to make your turret much more detailed and realistic. I do not want to see the turret we made in this tutorial in any future maps, ya hear? :-)
If you have questions or comments (concerning the tutorial, func_tank in general, or otherwise) please e-mail me. Remember that you can grab the example map that I came up with for this tutorial in the Files page. See ya! :-)
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.