WiseClip: Clipping

From Valve Developer Community
Jump to: navigation, search


This tutorial was originally created by wisemx. It was originally posted on SDKnuts.net.

Introduction

In the HL2 Source engine there are multiple methods for clipping.

  1. Clip/block the players movement.
  2. Clip/block NPC movement. (Zombies, etc.)
  3. Clip/block Physical objects.
  4. Clip/block Line of Sight.
  5. Clip/block sections with “portals”.
  6. Visible blocking with brushes.

With the exception of that last line the other 5 are all invisible once compiled.

The first thing we need to determine is what needs to be clipped and why. If you look at Valve’s example maps you can see that the developers are very kind. What do I mean by that? Notice that Valve clips areas that could possibly snag a player. For example, ladders should always be clipped since the player doesn’t really go up the ladder at all why let them get hung on it? This is a shot from Valve’s sdk_lockdown map:

Blank image.pngTodo: Couldn't find this map... checked 05, 06, 07, and 13 sp SDKs.

Notice how the ladder has that pinkish area surrounding it? The pink you see is a world brush with tools/toolsplayerclip applied to it. The golden colored cube you see is the func_useableladder. The purple squares are all info_ladder_dismounts. The ladder (prop_static) itself is only for appearance. Each of these objects works together to create the ladder and the clipped areas make sure everything is smooth. This ladder will work without them, the only benefit of creating a player clip in this case is to help the player.

Another use for a player clip would be someplace where they might do something they’re not supposed to, like Gravity Gun jump over a wall. You can create a player clip horizontally at the top of that wall to keep them from ever going over it, unless of course the cheat command noclip is used, then even Area Portals won’t stop them.

Here’s an example of a player clip Valve created to control the player:

A shot from the opening train station scene in HL2. The player will not be able to get over that fence because of the large clipped area.

Another example of a clip that should always be used is the typical wall columns. Just about every mapper creates some sort of section of the wall that a player could get snagged on. That’s the player clip we’re going to create for this example, step by step.

Creation

Column without clips. Columns like this are seen frequently in Half-Life 2's train station maps.

The first thing I’ve done is create a basic room for this tutorial, now the step by step part begins.

Create a column.

  1. On the right-side of Hammer click on the browse button to select a texture.
  2. In the filter input area enter “nodraw”.
  3. Double-click on the yellow nodraw texture.
  4. Click once with the Selection tool to select the wall for our column.
  5. On the left-side of Hammer click on the grey Block tool.
  6. Click and drag with your mouse to create the column in the Top view 2D window.
  7. Notice that because we selected the wall first our column automatically used the height of our wall, this is a big time saver.
  8. When the column is in the right place and is the correct size right-click on it in a 2D window and select Create Object.
  9. Our column exists but doesn’t look very nice. There’s an advantage to creating objects with the nodraw texture, when compiled none of the faces with the nodraw texture will show so they save on resources. All we need to do now is paint the faces that will show, the hidden faces like the back, top and bottom of the column don’t need any texture. Now our column looks beautiful doesn’t it?
  10. On the left-side of Hammer click on the Toggle Texture tool.
  11. When the tool opens click once on any face of the column. (This step isn’t needed but it’s a good practice so things don’t go wrong.)
  12. Click the Browse button on the tool.
  13. In the Filter input area enter “wall”.
  14. Double-click on the one you want to use.
  15. Experiment with the settings. For this example make sure Face is checked then right-click to apply that texture to any face of our column. Do this for all three exposed faces.
  16. I’ve used a more common method for the face texture on the column, while the Face Edit tool was open I left-clicked on an existing wall texture and then right-clicked on each face of the column.

Our column is created and it took less than a minute.

You can see there’s a good chance the player can get hung-up on that column just passing by it. Let’s create a solution for that.

  1. Click the Browse button on the right-side of Hammer.
  2. In the Filter input area enter “clip”.
  3. Double-click on the “Player Clip” Texture: (tools/toolsplayerclip)
  4. With the Selection tool click on the column to select it.
  5. Select the Block tool again.
  6. In the Top view 2D window create another column next to the first one, do this on both sides so you have three identical columns in the Top view.
  7. You could also create both of these extra columns by cloning the first one and then applying the tools/toolsplayerclip texture to them. Same method but for me the method I used for this tutorial is faster. You should learn how to clone objects, it’s going to save you a lot of time on certain tasks. You can clone objects or entire groups of objects.

Now we have two clipped areas. When the map is compiled those two additional columns will not show but the player won’t be able to walk there either.

But they’re not right are they? We need to turn those two columns into angled columns so the player slides right off them, just like butter.

  1. With the Selection tool select one of the Player clip columns.
  2. Click the Clipping Tool on the left-side of Ham
  3. Press Ctrl+E and in the Top view 2D window drag a line from one corner of the column to the opposite corner until you have a perfect triangle. You should see a red side and a white side. If the red side is not the side you want to clip away click on the Clipping tool again until it is, now press Enter. If you did it right the half we wanted to remove is now gone.
  4. Do the same for the other clip column.
  5. You could also clone the first column and flip it, but personally I like using the Clipping tool and it’s really fast.
This is our clipped column when we finish it in Hammer.
This is our clipped column in HL2, the player only sees the column but the player can not get stuck/hung on the column. Our work is done.

See also