How to make a wavy beam in 2D?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Diet Estus

I want to implement a wavy laser beam similar to the Proton Backpack in Enter the Gungeon.

It’s easy enough to draw a line from one point to another, but how to get the undulating curviness and the lighting effects?

How could one achieve a similar effect in Godot?

I will add this as a comment rather than an answer since I don’t know wether it would work or not.

What I would try is to calculate an array of points from beginning to end, and smooth a variation range with something like gaussian noise (that would get you soft curved paths), then just keep adding the next gaussian coordinate and deleting the first ones so it can flow.

I can’t add more since I don’t even know how to use the gaussian algorithm, but I saw something like this for Processing (although Processing actually have a next_gaussian() method that does the trick effortlessly).

rredesigns | 2018-08-28 18:37

You can make a series of lines which lead to a target, and then, using a Curve2D, smooth it out. The trouble with this method is you have to smooth out the curve at runtime. So you need to set the control points in the Curve2D such that they change with the position of the player, and the player’s intended target.

Ertain | 2018-08-29 19:59