Door antics... (Tutorial #4) W A V E L E N G T H
by HellBringer November 30, 1998
Foreword:
This tutorial assumes that you have both Half-Life and Worldcraft 2.0, and are fairly proficient in the use of Worldcraft, in that you have completed the previous tutorials in this series.
This article covers how to use:
- Brush manipulation
- Door Entities
- Entity Key/Value pairs

    Welcome to Tutorial #4 - This tutorial will be covering a few topics, as listed in the title. I'm going to keep the intro short (again); 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 did in tutorials 2 and 3.

  You came here for this tutorial, though -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 and my Compile FAQ for details.  I will be covering the individual commands each time we execute a new command for the first time.  

    Once Worldcraft has been loaded, go up to the "File" menu item and click on "open"Choose the file from our last tutorial, 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 some fun with DOORS. The func_door entities are some of THE most versatile entities in most Quake-engine games. Today I'm going to show you how to make doors that have to be "used" to be opened, triggered open (in 2 different ways), and doors that rotate.

  The simplest thing to show is a door that needs to be "used" to be opened. Before we do ANYthing, though, let's go ahead and Save our map AS "tutor4". That way our changes won't accidentally get saved into the "tutor3" map file. In whatever view you find easiest, select our door entity. Now, hit "ALT-ENTER" or "Edit | Properties" to bring up the entity properties dialog box. Click on the "Flags" tab.  Flags work like Keys, only they don't take a value - they're just "on" or "off".  Place a checkmark in the Flag that says "Use only".  Now close this dialog box, compile, and run the map. Notice that you have to walk up to the door and hit the "use" button to make it open? In every other respect, it functions just the same as a normal door.

  Now that we've learned how to make a door require one kind of action, let's move on to ANOTHER trigger type... This kind is known as a "walk-over" or "walk through" trigger. This gets a bit more complex; as we have to add some things to our map. First, zoom in once on each 2d view, then switch to block-creation mode and set your grid to 16 unit-spacing. Make a block 32 x 32 units starting in coordinates (80, -80) in the XY view. Adjust it in the XZ or YZ views so that it rests on the floor and is 32 units tall. This new block should neatly fit into the corner of our room. Once you've adjusted it to the proper dimensions, go ahead and hit ENTER to complete the brush-creation. Now, select our new "trigger" brush with the selection tool. Once we turn it into a trigger, it won't show up in the game - but it WILL show in our level editor... so let's make its texture something that reminds us of its purpose. In the texture box, hit the "browse" button. Now, in the filter window type "trigger"; then double-click on any of the "trigger" textures that it displays.

 

Here's how things should look just before you double-click...
 

  Let's apply this texture to our "trigger" brush by hitting the Apply texture tool . Lastly, let's make this an actual trigger. Hit the "to entity" button in the objects box.  If the entity properties window doesn't pop up, select our trigger brush and hit "ALT-ENTER".  You must change the entity class to "trigger_multiple". Trigger_multiple is a trigger type that can be re-activated over and over. We need a way to associate this trigger with our door. Luckily, there are handy "name" and "target" key/value pairs. So scroll until you see them, and in the "target" field (you will need to click on it) enter "door1" (without the quotes). This will be our target for this trigger. We're done for now, so go ahead and close the entity properties box. We need to name our door, so use the selection tool to higlight our door. Press ALT-ENTER and fill in the "Name" key with "door1".  It is now associated with the trigger. With the selection tool, grab our trigger brush once more. We put in one - but what about when the player gets on the other side of the door?? They need one on THAT side to come back through!! So go ahead and press "CTRL+C" to copy this brush. Also, press "CTRL+E" to center the views on it - this will make it easier when we paste it back in. In the XY view, scroll left (west) until the central part of the view is within the 2nd (western) room. Go ahead and press "CTRL+V" to paste in this brush. (NOTE: I'm telling you all these keyboard shortcuts deliberately... Using them saves a LOT of time over the course of making an entire "real" map.)  If necessary, grab inside the brush and move it in the XY and/or XZ / YZ views so that it is completely within our second room.

 

Here's my positioning of our two triggers...
 

  Go ahead and compile and run this map. See how you have to run over the (now invisible) triggers to open the door? Also, did you notice that you can still "use" the door?? We never changed that attribute - so it remains... triggers don't PREVENT the door from opening any other way, EXCEPT for walking up to it (i.e. walking up to it and NOT touching any trigger).

  Let's make it easier to find out how to trigger this door for the player, shall we?? Let's make our triggers Push-buttons that the player can press. First, go over to the trigger in the 2nd (western) room. Select it, and re-size it in the YZ or XZ view to be 16 units tall. Now, hit the browse button on the texture box. In the filter window, type "button". Go ahead and pick any one of the first 5 or 6 by double-clicking it (NOTE: I deliberately do this because our button is 32 units on a side, and I want a texture that evenly fits on it). Don't forget to hit the texture application button again !! Now, hit "ALT+Enter" to bring up the Entity properties dialog box. We must change the entity class from "trigger_multiple" to "func_button". Notice how the target attribute is preserved, however (if you click on "target", you should still see "door1" listed). For buttons, we must once again change the "angle" attribute so that it looks right. By default, the angle is 0, and this would make our button slide to the east if it was triggered. We need to change it so that when this button is pressed it moves DOWN (notice the button is on the floor - I want the effect of the button receeding into it). So click the drop-down arrow on the "Angle" field and select "Down".  Also, to keep the button from dissappearing INTO the floor, find the "lip" key and enter a value of "4".  You can go ahead and close the entity properties box now.

 

Here's our floor-button with all its attributes filled in as they should be (before closing the entity properties box)...
 

  Now, lets change our other trigger into a button. Select it and hit the texture application button (our Button texture should still be displayed in the texture box). Let's make this button a wall-mounted one, eh?? Go ahead and move it over so that (in the XY view) the upper left corner of the trigger brush is at coordinates (-112, 48). Now, resize the brush so that its right edge (in the XY view still) is on coordinate (-96) - this should make the trigger brush 16 units wide on the X axis in the XY view. This thing is starting to look like a button; however, its still sitting on the floor. Let's go to the XZ or YZ view and move it UP by 32 units (remember that the player is approximately 64 units tall, so this will put the button closer to chest-level).

 

Here's our trigger in position to be a wall-button...
 

  Now its time once again to hit "ALT+Enter" to edit the entity properties. Once again, change this entity to a "func_button", add the "lip" value of "4", give the "target" key the "door1" value, and adjust the angle. What's that you say? You don't know what angle to put in?? Well, here's a hint: Look at the XY view and assume we want the button to move "into" the wall its up against. This is to the WEST in the XY view. So, click in the Angle compass-dial in the westerly direction (the left-hand side). What number did you get close to?? If you said "180", you're correct. NOTE: the Angle line might not always line up perfectly; so ALWAYS go with the numbers. If you didn't get 180 on the nose, enter it in the Angle text-field. The compass will move to reflect this. 180 is DUE WEST (straight left in the XY view). All set?? Great, then close the entity dialog and test out your level by compiling and running it!  By the way, you may notice that the textures for the buttons aren't aligned.  I'm leaving this up to you if you want, refer back to turorial #3 if necessary to check how to align textures...

  Okay, so our buttons aren't really pretty - but I'll leave it up to YOU to do the texture manipulation at a later time to clean it all up.

  Note: Throughout the rotating doors section, I will NOT be specifying any sounds for the doors. You can go back and add them later; but for now please just follow the tutorial. Thanks!

  Now that we've done all kinds of moving doors and triggered doors, let's get fancy - let's have our door ROTATE. In Quake 1, making an object rotate was a VERY painful process - but luckily that's been solved for future games. The key to rotation in Half-Life is the ability to evnision a rotation POINT (like a hinge). You then insert what's called an "origin" brush along that hinge, set a few attributes, and voila! Care to try a few?? Great!

  First we're going to need to select our existing door and hit the "to world" button in the objects box. Then deselect the door. This is because we'll need to re-define our rotating door to include the origin brush we're about to create. Hit the "browse" button in the texture box and type "origin" in the filter field. Then, double-click on any of the "origin" textures that appear. Switch grid spacing to 8 units; and select the zoom tool. Zoom in a bit on the door in your 2d views. Then choose the brush creation tool. The origin brush's CENTER point is what will be used as the rotation point for our door - so we need to make sure that the center-point falls on a part of our door that makes sense. For example, create a brush that is 16 x 16 units in the XY view, starting at coordinates (-192, 8) and ending at coordinates (-176, -8). Then stretch this brush in the XZ or YZ view so that its top and bottom line up with the top and bottom of our door-brush. Press "Enter" to confirm the new brush.

 

Here's our origin brush (I selected it so it would stand out more)...
 

  You may see in the 3d view (depending on where its positioned) some of the origin brush. That's okay - origin brushes are invisible in the actual game. Go ahead and select both the door-brush and the origin-brush (select one, then select the other while holding "CTRL"). Click that magic "to entity" button (or use "CTRL+T"), and when the dialog box comes up, choose "func_door_rotating" as the entity class. Set the "name" field to "door1" (without the quotes of course), and let's look at something new: find the "Distance (deg)" attribute. This replaces the "angle" attribute with rotating objects. It determines how far (in degrees) the object will rotate.  Positive numbers ALWAYS rotate AWAY from the player; and negative numbers mean the object will rotate TOWARDS the player (no matter which side they stand on). For now, "90" is perfect.  Lastly, find the "delay before close" key and put "2" in this field (a value of "4" doesn't seem to work properly once the level compiles).

 

Here's our new rotating door!
 

  Go ahead and close the entity dialog box. Now, compile and run your map once more. Notice something??? The door rotates around its mid-point along one edge - so that when it rotates all the way, it goes "into" the wall some!! This is NOT good for a realistic door effect!  The way to fix this is to build a door-frame out of brushes, and re-size the door so that when it rotates, it doesn't stick "into" the wall, but butts up against it instead.  I don't have the time right now unfortunately to show this effect, but you can see it in many of Half-Life's levels where there is a swinging door.

  Now, you might be asking yourself - THAT seems kinda limited; you mean I can only have a door rotate clockwise or counter-clockwise on the Z-axis?? (Remember that our hinge point was running up and down, i.e. In the Z-axis) My reply to this is: Not at all!!   We do have to change the origin brush some, but you can rotate on any axis you like, provided you set the right flags. Flags are like entity attributes; except they work as checkboxes... either they are "on" or "off" (you don't assign various values to them)... you can access them from the entity properties dialog box by hitting the "flags" tab near the top of the box. Let's start by changing our origin brush, though- okay??

  Select our door and once again hit the "to world" button. Then select and delete our origin brush. With the brush creation tool, create a new brush in the XY view starting at coordinates (-192, 0). Drag over and down to coordinates (-176, -64). Then, in the XZ or YZ views, resize this brush to be 16 units high. Lastly, move the brush in the XZ or YZ views so that it sticks up above our door-brush by 8 units (so the center of the brush will be on the top corner of the door).  Press "enter" to create the brush.

 

Here's our NEW origin brush.
 

Once again select both the door and the origin brush (this getting familiar by now?? *chuckle*), and go for that "to entity" button. As before, select "func_door_rotating" and put "door1" in the "name" attribute field.  Lastly, find the "delay before close" key and put "2" in this field (for some reason, "4" doesn't work once the level compiles). Now, click on the "flags" tab. See the "X Axis" and "Y Axis" flags??? These determine what axis the door will rotate on if you don't want it to rotate on the "Z Axis" (this should be pretty obvious)... The way to determine which axis you want to select is to look at the XY view. We want our door to open like a garage-door this time around, so we want the "hinge" to be along the axis that the door is in. Notice our door sits running North-South?? This is in the Y axis, so this time let's select the "Y Axis" flag. Close the entity properties box, and compile and run the map to test it out.

 

The flags showing that the door should rotate in the Y axis...
 

  Okay, lastly we're going to rotate the door on the X axis. I'm not going to make this one pretty or very functional; but this is just a demonstration of what is possible. Just go back into the entity properties box by selecting our door and hitting "ALT+Enter", and change the selected flag from "Y Axis" to "X axis". Re-compile and run the map. See what this one does??? Notice also that it automatically took the mid-point of the Origin brush along the X axis - even though we had designed the origin brush for the Y axis.

  Well, at the risk of being a spoil-sport, I think I'm going to have to cut this tutorial short. We've covered a LOT of new information today; and I want some time for it to sink into you before we move on. Play around with these options; and see what you can come up with.  Some things I didn't cover, but you should try: Change the degrees of rotation, add sounds to your buttons and doors (with the "move sound" and "stop sound" keys), change the speeds of movement, and try changing your origin brushes to be centered in different spots. Next tutorial I'll cover the lifts, and delve into some lighting. 'Till then, take care and happy editing!

  As always, feel free to email me any comments, questions, or problems!

HellBringer's email address is: noelwade@hotmail.com

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.