FX Chain Lightning Tutorial
In this tutorial, we will learn how to:
- Build a lightning beam with the Lightning(Zap)node
- Build a small spark particle
- Add an animation note to an Animation Sequence
- Add the particle and lightning along with an animation command to an fx as chain lightning
This tutorial assumes that you have been through all the particle tutorials and are comfortable building a particle with minimal guidance. Should you need a review, please look at part 1 of the particle explosion tutorial.
Contents |
Step 1 - Create a Lightning Beam
From the create menu, create a ligtning node. Create/Lightning
This create a white ribbon of poly's that connects from a point near the camera(creation) and the origin of the area by default. It should be jittering all over and should look like the image to the right in fig 1.
Step 2 - Tweak the Lightning Beam Properties
Select the Start point of the lightning beam and open up the properties panel.- Under Texture section
- Set TextureName, choose the option box and pick this texture: /Engine/CleanGame/GlobalParticles/Textures/Sample/lightning_feathered_BW.dds. A white texture was chosen so that it can be tinted without color influence.
- Set TextureRepeat to 3
- Set the DiffuseColor to a light blue.
- Set the ColorAlongLength as an option if you like. Fig 3 demonstrates the color time line that I chose. It adds a subtle amount of variation.
- Under the Visuals section
- Set Divisions to 3. This makes it less jittery since there is few polygons to jitter around.
- If you want more control over the deformation you can experiment with the Deformation_X and Deformation_Y properties. These control the width of jitter.
- Set Lightning Width to .a Gaussian Value of Min = .003, Max = .24, Median at .08, and variation at about .11
- Set UVScroll to 5
We do not need to change the target for the other end of the node, because this will be in an fx that will ultimately be interactive based on game mechanic.
Step 3 - Build a small sparks particle
This will be a very similar particle to the explosion flash bang particle we build in part 1 of the particle explosion tutorial.
- Create a new local particle spec as a Basic Emitter and Billboard Point
- use the following texture, /Engine/CleanGame/GlobalParticles/Textures/Sample/sparks_4x.dds
- Add this particle to the area as an instance
Step 4 - Tweak Particle Properties
Tweak the properties so this resembles and explosion of blue sparks.
- On the particle property sheet - chain_lightning_sparks_tutorial_p.prt
- Set TextureNUmber to use all 4 quadrants
- Set the trajectory to have a Gaussian random value on each axis
- Set X and Z to a min and max of -.5 and .5 respectively
- Set Y to a min and max of -.25 and .6 respectively
- Set Bouyancy to 0
- Set the DiffuseColor to a timeline like in fig 5.
- Set LifeSpan to 2
- Set XScale2D and YScale2D to .1
- Set Size2D to a timeline value that allows the particle to get smaller towards it's death, like in fig 6, from a value of .06 to about .01.
- Set CollisionResponce to COLLIDE_BOUNCEDIE, This particle is only on for a fraction of a second so we may be able to get away with some collision response.
- On the emitter property sheet - chain_lightning_sparks_tutorial.prt
- Set EmitFrequency to .001
- Set NumberToEmit to 3
Step 5 - Create a New FX Spec
The FX editor is located in the clean engine tools panel. You can access this panel in two different ways. The first is to to hold control + shift and left click the upper left hand pixel in the viewport or press F5 while the cursor is in the viewport. Once open, go to the Tools tab under the Spec Oracles section and click on FX. This is a list of all the fx's in your world.
- Create a new FX Spec by choosing the Add button. This brings up a blank FX. Fill in a name and description. You can then turn off the Edit Spec Data Panel by toggling it's switch. It is also wise to name your fx group to something unique and descriptive of what your doing, since there can be multiple groups and they can be nested. Do this by double clicking on any node, it will bring up a dialog representing the node.
- Add a lightning(zap) node, and particle node, and an animation command node to the ChainLightningGroup. Click on each node to bring up it's properties and name them.
Step 6 - Tweak FX Properties
In order to do proper chain lightning we need a few targets. So using the /henpc command, create about 3 character_sample characters(/henpc create character_sample) and spread them out in front of your character. NOTE - they will be added where ever your character is standing at the moment, so add one, walk away, add another walk, etc...
On the preview panel in the fx editor set the Caster to Self, since your character will be casting the initial spell. Then select all 3 target characters and set the Target as Selection, then press Store Selected so that you can deselect everything to visually clear up the screen.
In the FX Task Browser
- Select the group node, ChainLightningGroup
- Set the FireRate to 1 second, 0:00:01.000.
- Select the Particle Node and adjust it's properties on the fx property panel.
- Set the resource name the the particle spec, in this example this refers to: \world\areas\262717511359\chain_lightning_sparks_tutorial.prt.
- Set WhenToStart to ONFXSTART
- Set StartFXName to the name of the group, ChainLightningGroup from the drop down.
- Set WhenToStop to ONFXSTOP
- Set StopFXName to the name of the group, ChainLightningGroup from the drop down.
- Set StartLoc and AttachTo to TARGET
- Set StartLocBone and AttachBone to spell chest( This is a bone that we internally picked to be on every character so that there is always a target for game events).
- Select the Lightning(zap) node in the FX task browser, and then also select the one in your in your area. On the FX Lightning property panel, press copy selected. This copies opver all the properties from your lightning node to the fx editors.
Press Preview and you should see sparks coming off of the chest of one of your targets
- Select the Lightning(zap) node in the FX task browser, and then also select the one in your in your area. On the FX Lightning property panel, press copy selected. This copies over all the properties from your lightning node to the fx editors.
- Set TargetName to the Particle FX node, Sparks from the drop down. A zap node can't target a bone by default, so by creating the particle that attaches to a bone first, we can then use it as a target for the zap.
- Set WhenToStart to ONFXSTART
- Set StartFXName to the name of the Particle FX node, Sparks from the drop down.
- Set WhenToStop to ONFXSTOP
- Set StopFXName to the name of the Particle FX node, Sparks from the drop down.
- Set StartLoc and AttachTo to Caster
- Set StartLocBone and AttachBone to Bip01 L Hand
Press Preview and you should see sparks coming off of the chest of one of your targets with a beam of lightning going from the caster left hand to the targets spell chest bone.
- FX node Property Panels
- Now Select the Animation Command FX node
- the only thing that needs changing here is to set the animation command. You can find this in the animation agent. Put the following code into the AnimCmd property on the Animation Command FX property sheet.
input Attacking combat_spellcast_left_sidearm
- CODE EXPLANATION - The animation commands will always be in a similar format and is largely dependant on your team impliments the animation agent for your product. Attacking is simply a variable name in the input section of the animation agent and combat_spellcast_left_sidearm is a sequence variable referring to the sequence combat_spellcast_left_sidearm
Press Preview and you should see sparks coming off of the chest of one of your targets with a beam of lightning going from the caster left hand to the targets spell chest bone all happening while the caster character plays a special animation.
SAVE
- Multi Target Behavior
Now for some experimentation on the group node. Select the ChainLightningGroup.
- Set the MultiTGTBehavior property to SPREAD and press preview. Lightning should go to all of your targets all at once.
- Set the MultiTGTBehavior property to SEQUENCE and press preview. Lightning should go to all of your targets 1 at a time.
- Set the MultiTGTBehavior property to CHAINED and press preview. Lightning should go to all of your targets, 1 at a time, with each target becoming the next caster.
Make it prettier
Now would be a good time to take the skills learned here and in the previous tutorials and make this fx more aesthetically pleasing. Possible additions could be
- Sound fx
- A flare or secondary particle to create a hot glowing spot that the sparks emit from
- A light
- An animation note on the combat_spellcast_left_sidearm sequence that would allow you to trigger the effect after the arm is extended instead of at the beginning of the animation.