Procedural Lightning

I spent some time yesterday refining my old code to produce a lightning effect that look fairly realistic.
Here’s a link to the source.

Here’s what it looks like after 6 iterations and 2 runs (729 parts ea.):

After 8 iterations and 6-ish runs (6561 parts ea.):

And then I stopped because my laptop can’t handle that much evil.

It’s a simple function that takes start and stop positions as well as some visual arguments (e.g. level of detail & jaggedness). All the docs are in the source.
The comment-to-line ratio is way above my average, so it shouldn’t be too hard to see what’s going on and modify the script to suit your nefarious needs.

4 Likes

Somebody needs to make a version of this that works alongside RIDI. Musicial tesla coils here we go!

1 Like

[quote] Somebody needs to make a version of this that works alongside RIDI. Musicial tesla coils here we go!

https://www.youtube.com/watch?v=jREWMrOs6rk [/quote]

Shut up and take my money :stuck_out_tongue:

What am I supposed to do with the script to get it to work?

It’s a module that returns a function. Put it wherever you want (ServerScriptService is fine) and run this in the command bar:

require(game.ServerScriptService.Lightning)(Vector3.new(0, 5, 0), Vector3.new(0, 15, 0), 0.35, 0.35, 0.2, 5)

The arguments are documented in the code.

this is exactly what i was gonna try today

edit: i found out this post is 5 years old sorry for bumping ;c

1 Like

Couldn’t you just add a sound and check if the lightning is active to play it? You may either add effects or edit it yourself to be like that