Collapsing Ceiling
You want to make a ceiling collapse, whether to let in combine soldiers or headcrabs, or just to give or block a route. In this tutorial, I?ll be showing you the basics. Keep in mind that these are a gimmick, and can be quite costly for system resources, so keep them sparse (One or fewer per map). I wouldn?t recommend them for multiplayer maps.
First comes the actual ceiling. For starters, you?ll need a room, I made mine nice and big, 512 units wide, 512 units long, and 256 units tall on the inside, giving me 67108864 cubic units of space, nifty.
We?ll also need a button to trigger the whole ceiling to fall, so make one, preferably right next to your player start. Make a brush, preferably with the dev/dev_measureswitch01 texture, tie it to an entity(Ctrl+T), and give it these values:
Class: func_button
Flags: Check ?don?t move?, and ?use activates?
After that, leave the button alone for the time being.
Now it?s time to make the actual ceiling. Firstly, make a square, 4 units or so thick, 64 units wide, and 64 units long, and place it a good way above the player.
[Image1]
Tie it to an entity, change it to a func_physbox, check the ?start motion disabled? flag, and give it the following properties:
Name: phys01
Material Type: Whatever material you texture your ceiling as, there?re many options.
This physbox is an individual ceiling tile, when the time comes to make the ceiling collapse, we will enable its motion, and it will be able to fall.
Now we need to cover the room with the tiles. Select the tile, hold shift, and drag it right next to its original location, to copy it to that new spot.
[Image2]
The two tiles will have the same name, but that?s all right.
Select the two tiles, and copy them the same way, and keep doing that until you?ve covered the entire room.
[Image3]
For my room, I checkered the texturing of the ceiling, so I can tell which piece is which.
I also left some headroom for the player so he doesn?t get crushed by falling tiles.
Now they?re all set up, now we just need to make them fall.
In order to do that, we need to enable the motion of every tile, but since they all have the same name, all we need is one output, and we already have a button, so let?s use that.
Give this output to your button:
[Image4]
When you press the button, the pysboxes? motion will be enabled(they?ll be allowed to move), and logically the first thing they?ll do is fall down to the ground, and that?s just what we want.
Compile it, run it in Half-Life 2(or any game, really), and press the button.
It turned out pretty lame, didn?t it?(comparatively)
That?s because they?re all falling at the same time. The way to make a falling ceiling that?s worth a damn is to make each tile fall at a different time, so let?s do that!
Use ?save as? to save the map as a new mapfile, we?ll need the old one for another demonstration.
For this example, we?re going to make the tiles fall in succession, towards the player, you could do it in the opposite direction, but I like this way better.
We?re going to need to name the tiles in waves, depending on what order they fall in. Look at the picture:
[Image5]
Name all the sets of tiles accordingly.
Now give your func_button these outputs:
[Image6]
Now each set of tiles will fall after another. You can increase or decrease the speed of fall by decreasing the delay time(.1 second intervals to .05 or .25 second intervals).
Compile, run, press the button, and watch.
Pretty cool, eh?
That?s all for directed collapses, but you still need random collapses, so keep reading.
Go back to the first map, the with all of the tiles falling at the same time, then continue.
Firstly, place an env_explosion wherever you want, above the actual ceiling tiles, I put mine in the middle.
Name it exp1, and set ?radius override? to 200, for an extra large explosion.
If you don?t want an explosion, just check every flag that begins with ?no?, except for the ?no damage? flag, you need that one to move the tiles.
Now go to your func_button. It should already have one output, the one that enables the ceiling tiles? motion, now it?s time to add another one:
[Image7]
Now the explosion will push the tiles .01 seconds after they?re allowed to move, so they really haven?t gone anywhere by then.
Compile, run, and press.
You can alter this example by adding multiple explosions, or bigger ones.
You can alter both examples by adding differently shaped tiles, tiles that don?t fall(func_detail or world brush), and different falling order.
Example Map 1: http://www.savefile.com/files/9300999
Example Map 2: http://www.savefile.com/files/5240479