This is an effect that I have been working on at work this last week. It's just a pet project but turned out quite good, so I thought that I would spill the beans and tell you how I did it.

This is a small AVI of the effect, it's all about getting the motion. It's only 227k so it shouldn't take too long.
If it opens in a new window, but doesn't play - click on it!

A nugget of purest green!...


I was looking at the lightning plugin that is on my other page and I was thinking, "This looks nice but how can I animate it?". Well after much scratching of head I figured it out. This tut will take you through many features of max including:- path controllers, expressions, and dynamic lofting. (wow, that all sounds good dunnit!). The main problem that I found with the lightning plugin is that it created lots of faces, no good if you need quick render times. My effect uses the minimum of faces and still looks as good. (of course thats just a matter of opinion). It has been designed so you can drop the effect into any future anim and alter a few figures, pull a couple of verts around and get a new effect.

I'd like to try your wootang style, lets begin then!


It's all based around the fact that you can alter the shape of a loft on any frame just by playing with the spline you used for the path. This is how the effect is created, the loft paths are given a noise modifier, and the values are animated. This is coupled with smaller off shoots of lightning following the main path and flashing on and off randomly. This is the first time that I've played with so many features in one project. It may seem a little daunting, and a lot of work just to get some jiggly lines, but I think it looks quite good, and you should only need to do it once!
Lets start off by drawing the main branch of lightning. Draw a spiky spline, be sure to put in quite a few verts as it helps later with the noise. A general lightning-esque shape should do.......

Next put in three other smaller branches, try to give them a shape that will look o.k at any position along the main branch. Now the first step of cunning! We need the smaller branches to follow the big main bolt, so set the pivot point of the small branches to one end. Next goto the motion menu (the little unicycle) and click on the position controller. The little green icon should lite up and you can change the controller type. Change it to path. Now you'll get a different set of options in the lower menu, find the pick path button and click it, then click on the main bolt of lightning. The smaller line will snap the the main one.
Do the same with the rest of the branches. it should then look like this......

Note: don't forget to link the smallest one to an off shoot and not the main bolt.

Too loud man, too loud!...


It's no good those lines sitting at the top like that, they need to wibble in a random type fashion!! Select a branch and call up the track editor. Expand the tree until you find the position controller and expand that. You will have an entry that is called percent (%!). This tells the line how far along the path it should be, so if we give it a random number it will jump about up and down the path like a maniac!
The way to do this is to give it a noise controller, click on the percent controller and change it to noise. Play with the settings until you get a nice wod of noise.
A few tips on this:- check the >0 button to stop getting results lower than 0. Set the strength to 100 - because the % path controller uses figures from 0% to 100% then it would be silly to have it go higher than this. You can get a good look at the noise that your generating from checking out it's function curve.

Do the same with the other branches......

Death by stereo....


Now we have lines that move up and down the main bolt in a random way. But the lines themselves don't change shape! Until now....
Give each branch an edit spline modifier and select all but the vertex that touches the main bolt (and for the main bolt itself all except the end verts). Leave this modifier in sub object mode, now give each line a noise modifier.
Give it these settings (or there abouts).......

Now your lines jump about on their own and up and down the main bolt - cool!

Big fat loft-a-thon.


Right, now we've got the line but they have no girth. They need to be solid. Lets loft the buggers!
I used a triangle for the loft shape because it needs so few faces. You all know how to do lofts so I won't go into that. Size the lofts so that it tapers off to almost nought at the end.
You should set the path and shape steps to 1 so that unnecessary verts are not created.
You will then need to link the lofts to their appropriate splines, so that the lofts move around with the lines. If your reading this then you know how to link stuff up.

Light my fire, Light my fire, Light my fire...


This lightning is on all the time, "but wait a minute, lightning sort of flashes on and off, doesn't it?" - your thinking. Hmmmmm, good point. O.K we need to slap on a visibility track. This etxra track tell the object which frames to appear in. A value above 1 and the object is visible, below 1 and the object is invisible. We need the main bolt to flicker on and off so...... Yes! it's time for the good old noise controller. In the track editor select the main bolt loft, you should see this icon become active - - click it to create a blank visibility track. Note:- If you've set your track editor to show only transforms the visiblity track will not show up, but it is there.
Slap on a noise controller and your main bolt now flashes on and off. Play with the noise parameters to get a nice falsh rate.

And now the end is near, I must face the final expression...


If you render up a quick test AVI you will see that just the main bolt flashes and not the smaller branches. Bugger! - we could put a noise controllers on them as well, but then we might get the main bolt hidden and smaller one showing. Hmmmmmmm......
What we need is to somehow tell the smaller branches only to flash whaen the main bolt is showing, and now you can with the power of expressions!
Before I go any further, I should tell you, that I am crap at maths and all that stuff. To get these formula I just played around until I got the effect that was needed,

NO technical knowledge is required!

An expression is a mthmatical formula that tell the controller what to do. There are a list of commands that can be used in an expression, and logical type descisions can be made. Give all the smaller branches a visibility track and make the controller - float expression.
When you alter the properties of the expression you are presented with a large window, the left hand side is for assigning variables and the right side is for the formula. There are 2 types of variable, scalar and vector. Now it's not as complicated as it seems, vector is anything that needs and X,Y,Z type of result, ie - position and scale. Scalar is any one number, ie - visibilty and %along a path. Now we need to create a scalar varialble.

Make sure the little option button is set to scalar, type in a name for the variable (anything will do), and then click create. Your variable name should now appear in the bottom left window. But this variable is not linked to anything yet, it needs to be the result of the main bolts visibilty track. Click on the variable and then click Assign to controller. Select from the list of controller the noise float for the main bolts visiblity. Whatever the result from the nosie contoller is now passed to our variable. So we can check this and tell if the main bolt is hidden or not!

Type in this formula in the right hand side box (the big one).

if ("your variable name">0,noise(100,sin(T),50),0)

Wow that looks complex! But hey I'll talk you through it.....
The if command is the checker - if (check, result if true, result if false) - if the check is true then the first number is the result, otherwise the second number is the result. The noise command is just a way of gatting a random number, it takes 3 numbers and creates a random number from them. But if you give it three static numbers it will always give you the same random number, so stick in a reference to time un some way. I used the default variable T. This is the number of ticks, it's a number that changes a lot every frame, but you could use F for frames if you want. The hundred and the fifty are just numbers I picked out of thin air, any will do. I took the sin of T because it looks funky! No other reason. :)
So in full the formula, checks your variable (which is the visibilty state of the main bolt) and checks if it is bigger than 0. If it is then the result is the random number created by the noise command, if it's not then the result is 0. Simple!

Note:- if your lightning has children of small branches, ie - if your smaller branches fork at any point. Then be sure to point it's variable to it's parent branch and NOT to the main bolt.

I got that funny feeling in my tummy...


O.K cool, now we've got our lightning flashing and jiggling and looking funky. if we slap on a dual glow it should be nearly finished.
This is the video post queue for the glows - if you need to know how it works check out the "glow like a trooper" tut.

The last little thing is to get a big light to flash on and off with the lightning, "clear enough miss Moneypenny, this should present no significant problems". You need to link the multiplyer of the light to the visibilty of the main bolt. With your new found knowledge on expessions it should be a breeze.
Go now and complete your mission, and may the Max be with you.