Unreal Realm of Concepts Home

Advanced Lightning In UnrealEd

In this tutorial, you will learn how to implement lightning effects. We will make a 'working' electrical storm. It will flash lights in the skybox, on the ground in the play area, trigger thunder that rolls to the distance, and bring down a deadly bolt.

I will not be holding your hand and telling you 'click this' and 'type in 128' and so on. This tutorial assumes you know basic editor functions. Please see these excellent resources first:

Stormy weatherBeginner's Part I

Beginner's Part II

Skyboxes

Basic Triggers

Advanced Triggers

Lights

There's a storm brewing...

Simple lightning is easy. There is a special subclass of light, DistantLightning. It is a flicking light that only comes on periodically. If that's all you need, just use that. You can put them in your map and/or skybox. I will call this 'heat lightning' because that's what we called lightning that was so far off, you couldn't see any bolts, nor hear any thunder.

Hey Zeus!

The DistanceLightning does not allow for syncronization of other things. We would like to have lightning in the clouds or our skybox, and maybe some streaks of lightning there too. And we want to sync thunder to it. And while we're at it, how about a bolt of lightning that strikes the ground, for fun, over some desireable pickup?

To get started, we first need to build the equivalent of a DistanceLightning. We need a random timed event. Et Viola there is a StochasticTrigger. You can set min and max times, and a probability within that range that an event will fire. Perfect.

We need to flash some lights off that trigger. TriggerLight!. But here's what sucks: TriggerLights can turn on, turn off, toggle on/off, or turn on for a time then shut themselves off (so far, sounds good), but the StochasticTrigger's events just fire. If you set the trigger to 'Control' or 'Pound' the lights stay on. We could toggle them on and off, if only we had some way of firing two events reliably after each other. Hmm. Dispatcher!? Yes. Add a Dispatcher, it is triggered by the StochasticTrigger. This sets the Dispatcher dispatching. Have the first two events fire your TriggerLights. The first event will turn them on, the second will turn them off. I tried to do this without a Dispatcher, but it just didn't seem to work. Lights never turned off, and I musta tried every combination of Control, Pound, Toggle, etc.. If you can figure it out, let me know. Dispatchers come in handy later, so it's not all bad.

The TriggerLights will now turn on and off at random. You can have however many you want, and they can be in the skybox or the play area, as long as all their Event Tags are the same as the two events fired by the dispatcher. Not very realistic looking, until you set the LightingEffect to Flicker. You got lightning! And, you have events you can rely on to fire other stuff.

On Donner, On Blitzen

So, now you have events you can use, let's add some thunder sounds. The AmbOutside package has some nice ones, but Unreall does too, and probably other packages. Depending on what you are doing, you may want a loud crack, big boom, or muted rolling thunder. Don't forget to check the explosions sounds to see if that's what you want.

To get the sound to play, add a Trigger/SpecialEvent. Set it's sound (not the AmbientSound) to be the sound you want. Set it's fire tag, but this will depend on what you want to do. If the lightning is close, set it to the same event the StochasticTrigger sent to initiate the lightning. If it's far, you can add a new event tag to the Dispatcher, and have it start the sound. You have a lot of control of timing there, which is nice. You must also set the SpecialEvent's Object properties initial state to 'play sound' but you have choices there too. If the lightning is close enough that everyone in the map should hear it, set to 'PlayPlayerSound' and they all will hear it. If it's localized, use just 'PlaySound'. If you use 'PlayAmbientSound', it will loop, and suck.

To get 'rolling thunder', choose other low thunder sounds, set events in the Dispatcher to fire them, and place them around the map. In my sample, I have a secondary flash which fires a circle of SpecialEvents for a lower thunder, circling the main strike. Then I have a third sound, in a circle around that. So no matter where you stand, you should hear the main strike, then the secondary, then the trailing, all from slightly different directions.

How about some lightning, Rod?

So far, we have nice atmospheric effects. Let's spruce things up with something deadly. Make a nice lighting bolt. I used two sheets, intersecting each other (looks like + from above) and textured them with a spark effect. I didn't look very hard, there may be a pre-made texture that will look better, or you can make your own. Make this brush as tall as your level, well, tall enough to reach the top of the map when the bolt is touching it's ground target. If you want the lightning to do damage to players, sheets won't cut it. So, now make a box to enclose the sheets, and AddSpecial, InvisibleCollisionHull. Glass, basically. This will provide the crushing power but let players see the nice textures inside. Intersect all with a box brush, add that as a mover, and set the first keyframe to be outside the map, and the next key frame in the map where lightning is striking. Set the move time to be small or zero, and the StayOpen time to be only as long as you want the strike to last, less than a second. I used. .5 seconds, but you do what you want. Set mover's enroach to Crush, encroach damage to 1000 or so. Set mover object initial state to TriggerOpenTimed. Then set Event Tag to the same as the StochasticTrigger's, so it will fire off at the start of things. Build and run. Zzzzap!

Make Benjamin Franklin Proud

It doesn't have to stop there. Here are some other things to try:

1. Use a TriggeredTexture (or several) to add streaks in the sky/skybox/clouds, etc. And if you don't need to damage anyone, you might use this instead of a mover.

2. You can set up several lightning strikes off this one set of Actors. And you could set up more of them, for truly electrifying effects.

3. Using movers and dynamic textures worked for me, but if you find this impacts your performance, try using normal textures and TriggeredTextures rather than movers. And if you can get a kill zone to fire, great (I think ZoneTrigger only works for gravity, but if you can get it to work, let me know).

4. Add a tornado! See Cyclone Tutorial

5. You don't have to use a StochasticTrigger. I did because it looks realistic, but you can use any trigger. For example, if you want a fancy 'triggered death', use a trigger to bring down a lightning bolt on the sucker or other players. Maybe nice for a Wizard's Lair or something. Use a RoundRobin, another Dispatcher, or CodeTrigger for even more fun.

Try This

Example Map: AStorm.zip (10k)

When I can get around to it, I'll put details on this map here. What you need to know: there is a main event which is loud and deadly. There is a secondary flash in the skybox with delayed thunder. There is a third event for more thunder only. While the main bolt is active, there's another mover in the skybox that lights up the sky in conjunction with the triggered light there. It's pretty dramatic.


References:

Freakin' Excellent Tutorial Sites:

UnrealEd

Wolf'S Unreal

Dr. SiN

Unreal Tutorial Database

Unrealized

Back To Unreal Realm Of Concepts Home