How does TDS make this lightning effect?

So, the accelerator tower makes this really cool lightning effect, and I was wondering how they did it. Slap Battles also uses this too.

1 Like

You probably just need to create a few points in between Lighting Origin and Target. After that you can Randomly Offset their position every frame and then make visible parts connecting those points.
EDIT: You can make it look smoother by using math.noise().

Check this

1 Like

it is just generating random joints between parts and rotating them to a certain random degree

You have 2 Vector3 values: startPos and endPos. Using Lerp function or doing your own math, you create multiple points between those two values, while also adding random X, Y, Z values to turn it from a straight line into a lighting-like path.

You should end up with a table, where the first element is startPos, last element is endPos, and between them are the points that you created.
To create lighting parts, loop through the table using for i = 1, tableLength - 1 do loop. The - 1 is important, since the last element doesn’t have next element.
In the loop, you will have 2 Vector3 values: pos1 and pos2. Calculate distance by doing (pos2 - pos1).Magnitude.
Size of the part will be Vector3.new(1, 1, distance) (1 is your lighting thickness).
Set CFrame of the part to CFrame.lookAt(pos1:Lerp(pos2, 0.5), pos2). By using Lerp with the value 0.5, we place the part in between of our 2 points, and it will be oriented towards the next point.

3 Likes