Half-Life 2 Deathmatch Tutorial III: Triggerable Trapdoors

Babel Babel Logo

In this tutorial I will demonstrate how to create a deadly trapdoor triggered by throwing physics objects at a certain point. In our HL2DM mod Babel Babel, the teams playing against each other have the option of throwing boxes lying around the arena at targets on the other teams’ side of the level that trigger a series of trapdoors in the ground. If one of the enemy teams’ players happens to be standing over one of these hidden trapdoors, he will face his certain death at the bottom of the pit.

I had some trouble getting this trapdoor to work at first, since it seemed to work fine – as long as no player was standing on it at the moment it was triggered. In this case, it simply refused to open at all. After browsing the net a bit I found several hints on how to make the trapdoor work correctly and combined them in the following tutorial. As always, you should already be a little familiar with Hammer, because I won’t tell you all the icons you have to click on.

What you need for this level is a room with a hole in the floor and a vertical duct beneath it for the player to plunge to his death. And don’t forget a spawn point of course.

The room layout in side view

  1. We will start off with creating an invisible “hinge” for our door, which will control the “real”, visible door. Create a very small block and make it a func_door_rotating. Place it in the center of the right hand side of your trapdoor hole in the top view and align it with the surface of the room’s floor. Give it a name, let’s say “trapdoor_hinge.” Set the entities’ Speed to 5000. It needs to be a really high value, otherwise the player will probably get stuck in the door. Set the Distance to -90, so that the door rotates 90° downwards. Go to the Flags section and activate both “One-way” and “Y Axis”. You’re finished with the properties of this entity now, all that’s left to do is change the texture for the brush to nodraw, since we don’t want to have it showing up in-game.
  2. Now for the actual door: create a brush the size of your hole in the ground. Convert it to a func_brush entity and move its origin (the white circle in the center of the brush) to the middle of the right side of your brush, so that it overlaps with the trapdoor_hinge brush. In the properties of your newly created entity, give it the name “trapdoor” and set its Parent to “trapdoor_hinge.” This will make sure that the trapdoor is actually moving along with the hinge. Go to Solidity and set it to Always Solid and change Solid BSP to Yes. These two options make sure that the collision between the player and the door actually works. Take a look at the screenshot, this is what you should have now. It shows the top and side view of the trapdoor and hinge in place.
  3. The trapdoor and hinge brushes

  4. What we need now is a way to activate the trapdoor. In this case, we will activate it by throwing a physics object at a target brush. So create a brush that you want the player to hit and place it somewhere in the room (it should be reachable by throwing an object with the gravity gun at it.) Create a second brush, place it directly in front of your target (or around it, if you want the target to trigger from all sides) and give it the trigger texture. Convert the brush to a trigger_proximity entity, and open its properties. For the name, type in “trapdoor_trigger.” Point to measure distance from should have trapdoor_trigger in it. In the Flags options, make sure that the only flag checked is Physics Objects. We need one Output for the trigger – Add a new output called OnStartTouch, targeting trapdoor_hinge via the input Open. Once the box touches the trigger, it will automatically activate the hinge of our trapdoor and thus open the actual trapdoor.
  5. The target and trigger in place

  6. Place a prop_physics in your room and choose a World Model for it, for example cardboard_box001a.

You are now ready to compile and run your map. If you pick up the physics object with the gravity gun and throw it at your target, the door will open. You can also add a trigger_hurt to the bottom of the pit if you want to make sure that the player actually dies.

Also check out the previous chapters of this tutorial series:

Part II: Round Gameplay

Part I: Making Sure Players Are Ready

Tags: , ,

Leave a Reply

Enter this code