This entity can be placed in the levels and Track View cinematics to create electric like effects. It creates electrical arcs between two or more points.
You can find it in the RollupBar create tab under Entity. In the Browser expand 'Environment' where you find 'LightningArc'.
After being placed, it will need to have a lightning preset, a material assigned and at least one Target entity in order to work.
While active, it will spark a new electric arc to one of the assigned entity targets randomly.
The entity will be able to trigger new sparks either in game mode or AI/Physics mode. In editor mode, the entity will always be disabled.
Making it work - Checklist
Here is a list of steps you need to take in order to make sure it works:
- Your LightingArc entity is Active.
- Your LightingArc entity is Entity-linked to at least one TagPoint.
- Rename the Link name to Target (Is NewLink by default).
- AI/Physics is on.
- Your LightingArc has a lightning material assigned (
- The ArcPreset on your LightingArc object has a valid entry assigned (Default is assigned by default).
- To make changes checkout
- After changes reload via CVar: g_reloadGameFx.
- Refer to the Lightning Preset Setup section below.
- To make changes checkout
If set to true, it will automatically start sparking after jumping into game.
A valid preset must be given. This will tell how the lightning arc will look like.
Delay in seconds between sparks.
Time randomization in seconds.
Any material with Illum shader can be used but a specific setup will be needed to have good looking spark effects. To apply the material to the LightningArc, just normally apply the material to the entity like you normally do with any other entity type.
All the selected electric arcs will start using that material.
It is recommended to use a diffuse texture that slightly looks like a beam of electricity (or you can be creative!) in 99 transparency in additive mode and a bit of glow. As you can see from the picture above, the texture has 4 beams.
The lightning will warp around the U coordinate and use the V coordinate as a multi-frame animation.
Enable / Disable
Allows to dynamically enable or disable the internal timer.
Allows to manually trigger a spark even when the entity is disabled.
The entity that was last struck.
The time the last spark will spend to fade out.
Lightning Preset Setup
To setup the lightning visuals, open the following file:
The smooth snaky effect given to the lightning in meters.
The noisy effect given to the lighting in meters.
After a spark is triggered, it will start to shift from its original position upwards.
Should be kept at either 0 or 1 but either values can be used. It will allow child branches to strike out of the main beam and child sparks to branch out of other child beams if this value is 2 or higher.
How probable a child is going to spark from another beam segment. If set to 0, no branch is generated, 0.5 there will be a 50% probability of sparking a branch, 2.0 will have a probability of sparking 2 per beam, etc.
Hard limit on the number of beam segments that can be generated regardless of previous parameters.
Minimum time a spark is kept alive.
Maximum time a spark is kept alive.
When the spark dies, it will take this time to fade out into oblivion. Actually it will decrease its beamSize to 0 instead of actually fading via transparency.
Number of snaky segments generated.
Number of points per segment generated to create the noisy effect.
Width of the beam being generated. Child beams while have half of the width.
Texture tilling depends on the world size of the actual beam being mapped. A value of 2.0 means the texture will wrap around twice every meter.
The U coordinate will move in a given direction at this value's rate. While beamTexTiling will only affect the U coordinate, the V coordinate will be automatically calculated to select one of the texture's frames.
Number of frames in the animation.
Frames per second of the multi-frame animation.
Since the lightning effect is implemented within the more general Game Effects, it will be possible to reload during run-time all the parameters for fast edit.
All you have to do is put g_gameFXSystemDebug to 1 and then every time you press 'numpad .', all the game effects parameters will be reloaded and will take effect right away. You can also run the console command g_reloadGameFx for the same effect.
To trigger a lightning effect through code (check LightningBolt.cpp for live examples), all you need to do is:
The lightning game effect will manage automatically the update positions. STarget supports any given position given by code, an entity id to keep track of the position automatically or a character attachment to align the spark to a specific point of your entity.
Please check CLightningGameEffect for the full code interface.
LightningArcs in Cinematics
In Crysis 3 and its cinematics we made extensive use of this cool entity!
While of course you can animate the position of that LightingArc and Target-TagPoint and Enable/Disable its state or use 'Strike' via Track View:
You can also add some nice functionality via Flow Graph magic like light emitting on Strike or particles appearing on the arcs ends (which could also get you some sound).
You actually won't need much more stuff in Track View so I'll keep manageable:
But there is a little something in the background to make this happen. Here are the ingredients:
- 2 of your electric sparkle particle objects.
- Link each to the LightningArc object and the target TagPoint.
- Remove any position offset so that when selecting one of the particle objects move tool will show 0 0 0.
- If you move the acrs while striking a glow covering the arc ends using Move Rel Emitter could help.
- One light with a fitting color and average range (approximately, depending on how big your arcs will be).
- A Track Event in your sequence.
- Create it with the Edit Events option from Track View list context menu.
- In the TrackView Events window click Add and give it a decent name.
- To use it you need an arbitrary Track Event track.
- Create one with the Add Event option from Track View list context menu.
- The name of this track doesn't matter - its like a folder.
- Double click on Track Event track creates a key.
- Double click on key pops up the key popup in which you can select your event under Track Event.
- A Flow Graph which utilizes your Track Events.
- Create a new one via right click on LightningArc or use an existing one.
- Right click in empty space and Add Track Event Node.
- In Track Event Node select your sequence and the actual Track Event appears.
- This output you can use to trigger everything. An example can be found below.
To explain this one: We have 2 GetPos nodes for TagPoint and LightningArc to aim the particle objects (you could of course skip that if you have an even emission all around) and to create the mean position for the light. The particles and light are turned on and off again with delays.
Copy/Paste this right away if you like (Paste with connections via Ctrl+Shift+V):