Tutorials

Creating Breakable Lamps



I've been browsing around this site unregistered for quite a while now and I decided it's time for me to give something in return.

I was looking around here and on a couple of other sites with Hammer tuts and I never managed to find a tutorial about breakable lights. If you for example use a prop_static for your light model and a light_spot for the light itself you can't just make the light turn of when the model is shot at (as far as I know). So after playing around a bit I found a way that works and here it is:

1. Create a prop_static which will be the lamp itself. Then go into the props properties and choose a model for it. My lamp will be lampfixture01a as it is a lamp that is easy to stick up on walls.

news post image

2. Next step is to create the light source. I always use light_spot after reading SgtJman's Advanced Lighting tutorial (Which I will borrow some other tips from too). There are two important things to think about when creating the light.
First of all you don't want it to actually be inside the model. It actually doesn't matter if it's a couple of units away from it as it only project a light on the nearest surfaces and you can trim it to look good using the properties later.
The second thing is that you want the light to point in the right direction. Not all lamp models have a straight -90 degree pitch. The one I chose for example has a pitch closer to -75 degrees (-76.5 looks the best according to me). This is quite important if you want your light effects to look good in your map.

news post image

3. Next up is the light beam. This is created with the help of point_spotlight.
Same thing here as for the light source, you don't want it to be inside the model and you need to adjust the pitch. Although since this is the beam of light it has to be as close to the prop as possible. I'm not sure how close it can be, so you will have to test that. This is because if it's too far away the beam is going to start in the middle of the air and not at the lamp like we want it to.

news post image

4. From here there are various ways to improve the light, such as altering colors, brightness and adding sprites, to make it look more realistic but as this tutorial is about breaking the light I won't cover that. Instead I recommend the same SgtJman's tutorial.

5. So now on to the fun parts: Destroying the light.
For this to work we need some sort of trigger to turn all the lights off. As the normal trigger_once only triggers on being touched by a player (Once again, only as far as I know) I decided to be a little more creative.
Create a brush and place it in front of the glass part of the lamp. Make sure that the whole brush uses the Nodraw texture so that it won't be visible. Once you have lined it up good press Ctrl+T (Tie to Entity). Select the entity func_breakable and press apply.

Preview (Clicky clicky):
news post image

6. The reason I didn't say anything about changing any properties earlier is that I find it a lot easier if you do it all at once, so that you don't have previous changes that you don't remember making screwing it up for you (Believe me, it has happened). So now it's time for the changing.
First thing you need to do is name all parts of this except the prop. I named them as follows to make it easy:
light_spot Name: Light01_Light
point_spotlight Name: Light01_Spotlight
funk_breakable Name: Light01_Trigger

7. As lamps also has a protective cover of glass which breaks when you shoot at it you can add more realism by making the funk_breakable a bit of glass which produces a few gibs.
To do this you need to make sure that the following conditions are met:
Material Type: Glass
Prop Data: Glass.Small
Now I don't know if this is a bug in my Hammer or something, but when I set Strength to 0 the glass breaks really easy even though it says in the tooltip "0 means don't break". Either way, set the Strength a low value so that the glass will break easily.

8. The final thing you need to do is set up the triggers to turn the light off when the glass is broken. This is done through a series of outputs from the funk_breakable. Here is the list:

My output named: OnBreak
Target entities named: [Name of the light_spot]
Via this input: TurnOff
Fire once only: [x]

My output named: OnBreak
Target entities named: [Name of the point_spotlight]
Via this input: LightOff
Fire once only: [x]

This one is optional if you happen to have a sprite, as they don't seem to have a "TurnOff" type of input.
My output named: OnBreak
Target entities named: [Name of the Sprite]
Via this input: Kill
Fire once only: [x]

Once you are done, your outputs should look like this:
news post image

That should cover it all, now save and compile your map and boot up whatever game you made it for to test it. If any of the lights aren't appearing then try moving them a bit further away from the lamp model, as they are probably inside.


This is what it looks like:
news post image
news post image

-Avalyst

View comments ( 9 )

Back to top