Snarkpit Articles

Dynamic Light

Introduction to the light_dynamic entity
This tutorial is basically a continuation of my tire swing tutorial, which describes how to make a hanging prop that will move around if shot, but with different props and dynamic lighting. So having read that tutorial, make a light using similar methods:

Article image


I have used the props_c17/lamp_bell_on.mdl model for the prop_physics in this example.

Before you start reading on, all your entities and your
prop_physics must be named. I will be using these names for this tutorial:

prop_physics = dynamic01_lamp01
move_rope = dynamic01_rope01
keyframe_rope = dynamic01_keyframe01
phys_lengthconstraint = dynamic01_constraint01

Swinging light

Now, go into the properties of your prop_physics light. Now, this is very important: you MUST change it from a prop_physics to a prop_physics_override. This is done from the drop down menu where it gives the name of the entity currently selected. After that change is made press apply.

Now it's time to create the light that will follow the lamp and light up the area the lamp points. Create a light_dynamic right below your lamp. Press enter to create it. When you do you should notice that your 3D View gets filled up with all sorts of lines and cones and stuff.

Article image


That?s what if should look like. Go into the properties of your dynamic light. Set these properties:

name = dynamic01_light01
parent = dynamic01_lamp01
pitch yaw roll = 90 0 0 (this is down)[/color]
brightness = 4 (4 is the maximum and 0 is minimum, you may need to play around abit)
Spotlight end radius = 200 (This is quite large, you may want to fool around. It is the radius of the big white cone you see in your 3D view)

Make sure you press apply to set all these changes.

Article image


Run your map and hopefully you have something that looks like that. Now, HL2 doesn?t recognize light_dynamic as a light source and sets the map to fullbright by default if you don't have any other 'normal' lights. If this is the case, go into your console and type sv_cheats 1 and then mat_fullbright 0.

If after you do that you don?t have something that looks like the picture, one thing you might want to try is selecting your light_dynamic and looking in your side view- there should be a circle. Drag this so it?s the size of your room and press apply. Another thing you should check is your brightness. The brightness is VERY important: if it is 0 then you will have no light at all, so make sure it is at 4.

Spotlight effect

When that is all working, and you?ve had some fun shooting your light around the room, its time come back to Hammer and add a spotlight. Create a point_spotlight entity right below your lamp. Go into its properties and set these following settings:

name = dynamic01_spotlight01
parent = dynamic01_lamp01

You might want to tick the no dynamic light flag too as we've already got a light source and doing so will save processing power. Now press apply, and compile/run your map!

You should have something that looks like this:

Article image


And that?s pretty much it. You may want to add a dim light in the room so you can sort of see the walls. But besides that, this tutorial is over.

Discussion

Posted by Gumsy on Sun Jan 9th 2005 at 5:16pm

Nice tut. I personally use phys_ballsocket or phys_pulleyconstraint instead of the lengthconstraint as it stops the object from shaking quite as much.
One thing I'm confused about is the keyframe_rope 's parent option. It doesn't work with me, when i use it it goes from the initial move_rope to the origin of the map rather than the keyframe :-/ I've been told by a few people that this is just a glitch with SDK, so instead i use logic_measure_movement to attach it to the object, though it doesn't look fantastic, has anyone else seen this glitch?
Posted by Yesurbius on Sun Jan 9th 2005 at 4:00pm

Posted by habboi on Sun Jan 9th 2005 at 3:17pm

Thankyou for explaining it to me. I will apply it to my maps now! Thanks
Posted by bulleteater on Sun Jan 9th 2005 at 2:52pm

Nice! I've been waiting for a light_dynamic tutorial like this one.