Lightning

From Valve Developer Community
Revision as of 07:09, 19 August 2006 by Andreasen (talk | contribs) (Cleaned up the article a bit. Will continue after I'm finished *crying* over its previous state.)
Jump to navigation Jump to search
Broom icon.png
This article or section should be converted to third person to conform to wiki standards.
Broom icon.png
This article or section needs to be cleaned up to conform to a higher standard of quality.
For help, see the VDC Editing Help and Wikipedia cleanup process. Also, remember to check for any notes left by the tagger at this article's talk page.

Note: This article is under construction today. I'm just making a temp save and taking a breather.

Lightning test 01 screenshot0003.jpg

This is a tutorial for adding a lightning storm to a map.

It will use custom made lightning sprites (lightning.vmt and lightningglow.vmt) which can be downloaded here (along with an example map). However, the following sprites already included in the SDK can simulate lightning suffciently too:

  • bluelight1
  • lgtning
  • lgtning_noz
  • physcannon_bluelight1b

It is assumed that the reader knows how to create a 3D skybox before reading this tutorial.


This setup will make the lightning automatically start on. You will have to do some random triggers if you want it to only be on at a certain part of the map.


Setting up the sprites

Unless lightning is intended to be close enough to strike within the playing area, create the 3D skybox that will house the lightning storm. Make sure that its fog is disabled.

  1. Place 2 env_sprites about 2-10 units away from each other. (Make sure ones in front of the other.)
  2. Select the one closest to the skycamera entity.
  3. In the Sprite Name box write the name of the glow sprite to use for the lightning glow. (The pictures will use the custom materials/sprites/lightningglow.vmt sprite.)
  4. Set its Scale to 7.
  5. Make sure Render Mode is additive.
  6. Make sure that the FX Amount is 50.
  7. Also change the Name to lightning1glow.
  8. After that click Apply and then Cancel.

Open the properties of the other sprite.

  1. Type a name (like lightning1) in its Name field.
  2. Change the Sprite Name to the name of the lightning sprite to use. (materials/sprites/lightning.vmt)
  3. Make sure the Render Mode is Additive
  4. Make sure that the FX Amount is 255.
  5. Change the Scale to .75.

Timing between strikes

Place a logic_timer in the map, preferably somewhere near your sprites. Open its properties and make the following alterations:

  1. Name it. (lightning1timer)
  2. Make sure Use Random Time is set to yes.
  3. Make sure Min Random Interval is set to 1.
  4. Make sure Max Random Interval is set to 10.
  5. Set Refire Interval to 0.35.
  6. Click on the Outputs tab and add some things to make it look like this:

http://img162.imageshack.us/img162/6269/step202af5.jpg

(Important Note: The example shows the number 2 but in this tutorial number 1 is used so just replace the 2 with 1. Also the Last line is an optional part of this tutorial!) Once you're done that click on the flags tab and make sure the only flag that showing is checked!

Done. Save it and test it out. The steps below are optional.

Adding thunder

To add some thunder sounds it is recommended to use a soundscape (which is not covered by thia tutorial), but a quicker way is to place an ambient_generic somewhere in the map - not in the 3D skybox - and change its name to Thunder.01, change its sound name to k_lab.teleport_post_thunder or another good thunder sound. Then go back to the logic_timer and add "OnTimerLow" "Thunder.02" "PlaySound" to the output tab. You can also set a delay that will reflect on how far away that the lighting is.

Randomized lightning

To prevent the lightning from hitting the same spot twice, you can make the sprites rotate around the skybox. (This doesn't actually show the lightning strikes moving.)

  1. Create a small brush textured with the invisible tool texture.
  2. Turn it into a func_rotating entity.
  3. Call it lightningrotator
  4. Change the max rotating speed to 3.
  5. Change the friction to 20.
  6. Click Apply and close its window.
  7. Go back to your two sprites and change their parent to lightningrotator.
  8. Add a logic_auto to the map (Not sure if this is needed or not...)
  9. In its Outputs tab add this:

"OnMapSpawn" "lightningrotator" "Start"

  1. Save and test the map.