Skip to content

Optimised, Lightweight, and highly customisable Lightning Effects for use in Roblox. Uses layered, moving perlin noise, uniform disk-point picking, and bezier curves.

License

Notifications You must be signed in to change notification settings

easy-games/Lightning-Beams

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


Optimised, lightweight, and highly customisable Lightning Effects for use in Roblox. Can be made into all sorts of special effects.

Features:

  • Layered, moving Perlin noise
  • Uniform disk-point picking for even distribution of control points
  • Can go along a Bezier curve rather than just straight-lines (i.e. Similar to how rblx beams curve)
  • Varying thickness, length, and, transparency
  • Can use ColorSequences
  • Lightning "Sparks" and "Explosion" sub-modules
  • Can smoothly travel as a projectile trying to reach a point

Table of contents

Showcase

ezgif com-gif-maker ezgif com-gif-maker (2) ezgif com-gif-maker (4)

Usage

This section shows the entire API for the main module (LightningBolt) and sub-modules (LightningSparks, LightningExplosion). Default values for properties are in the code.

Example

local LightningBolt = require((...).LightningBolt)
--Create a new bolt with 40 parts
local NewBolt = LightningBolt.new(workspace.Attach0, workspace.Attach1, 40)
--Then, update properties to your liking
NewBolt.CurveSize0, NewBolt.CurveSize1 = 10, 15
NewBolt.PulseSpeed = 2
NewBolt.PulseLength = 0.5
NewBolt.FadeLength = 0.25
NewBolt.MaxRadius = 1
NewBolt.Color = Color3.new(math.random(), math.random(), math.random())
local NewSparks = LightningSparks.new(NewBolt)

LightningBolt

LightningBolt.new(Attachment0, Attachment1, PartCount)
Creates a bolt at source Attachment0 which flows into sink Attachment1 with number of parts PartCount

LightningBolt:Destroy()
Cleans up and clears from memory

Appearance Properties

Enabled
Hides bolt without destroying any parts when false
Attachment0, Attachment1
Bolt originates from Attachment0 and ends at Attachment1
CurveSize0, CurveSize1
Works similarly to beams. See https://dk135eecbplh9.cloudfront.net/assets/blt160ad3fdeadd4ff2/BeamCurve1.png
MinRadius, MaxRadius
Governs the amplitude of fluctuations throughout the bolt
Frequency
Governs the frequency of fluctuations throughout the bolt. Lower this to remove jittery-looking lightning
AnimationSpeed
Governs how fast the bolt oscillates (i.e. how fast the fluctuating wave travels along bolt)
Thickness
The thickness of the bolt
MinThicknessMultiplier, MaxThicknessMultiplier
Multiplies Thickness value by a fluctuating random value between MinThicknessMultiplier and MaxThicknessMultiplier along the Bolt

Kinetic Properties

  • Allows for fading in (or out) of the bolt with time. Can also create a "projectile" bolt
  • Recommend setting AnimationSpeed to 0 if used as projectile (for better aesthetics)
  • Works by passing a "wave" function which travels from left to right where the wave height represents opacity (opacity being 1 - Transparency)
  • See https://www.desmos.com/calculator/hg5h4fpfim to help customise the shape of the wave with the below properties:

MinTransparency, MaxTransparency
See https://www.desmos.com/calculator/hg5h4fpfim
PulseSpeed
Bolt arrives at Attachment1 1/PulseSpeed seconds later. See https://www.desmos.com/calculator/hg5h4fpfim
PulseLength
See https://www.desmos.com/calculator/hg5h4fpfim
FadeLength
See https://www.desmos.com/calculator/hg5h4fpfim
ContractFrom
Parts shorten or grow once their Transparency exceeds this value. Set to a value above 1 to turn effect off. See https://imgur.com/OChA441

Color Properties

Color
Can be a Color3 or ColorSequence
ColorOffsetSpeed
Sets speed at which ColorSequence travels along Bolt

LightningSparks

LightningSparks.new(LightningBolt, MaxSparkCount)
Creates Lightning Sparks which fly out from LightningBolt up to a maximum of MaxSparkCount

LightningSparks:Destroy()
Clears from memory

Properties

Enabled
Stops spawning sparks when false
LightningBolt
Bolt which sparks fly out of
MaxSparkCount
Max number of sparks visible at any given instance
MinSpeed, MaxSpeed
Min and max PulseSpeeds of sparks
MinDistance, MaxDistance
Governs how far sparks travel away from main bolt
MinPartsPerSpark, MaxPartsPerSpark
Adjustable

LightningExplosion

LightningExplosion.new(Position, Size, NumBolts, Color, BoltColor, UpVector)
Size: Value between 0 and 1 (1 for largest)
NumBolts: Number of lightning bolts shot out from explosion
Color: Can be a Color3 or ColorSequence
BoltColor: Can be a Color3 or ColorSequence
UpVector: Can be used to "rotate" the explosion

LightningExplosion:Destroy()
Cleans up and clears from memory

About

Optimised, Lightweight, and highly customisable Lightning Effects for use in Roblox. Uses layered, moving perlin noise, uniform disk-point picking, and bezier curves.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Lua 100.0%