How to do laser?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By grol
:warning: Old Version Published before Godot 3 was released.

Hey guys,

how would you do laser? At the moment i would use it in 2d but maybe 3d is coming soon. I thought maybe simple line with hdr glow? Or is there a shader to use for this? Or maybe particles?

Your ideas are very welcome!

:bust_in_silhouette: Reply From: grol

my first try to draw a line and then give it a glow totaly failed. Anyone knows how i can prevent the glow to behave like on the screenshot? I like to have it all around the line…

Image is broken

Bojidar Marinov | 2016-03-26 17:54

:bust_in_silhouette: Reply From: Gokudomatic2


I implemented a SW laser effect in my game. It probably isn’t what you’re looking for but I share it nevertheless because it’s a quite efficient trick.

A laser beam or laser saber in SW is in fact easy to reproduce with 2 cubes (testcube) of different color (like red ans light pink) and both superposed. And setting both material to inverted faces gives this typical shape of the laser. CPU Cost: only 2 cubes.
After that, I stopped there but you can maybe implement a blur shader to make a better effect. I’ve alas no knowledge in shaders.

@Gokudomatic2 Can you provide a small tutorial how to do that?

vctr | 2017-03-26 13:39

:bust_in_silhouette: Reply From: hearto

Like this ones from my game?

Laser in a nutshell

Create 3 sprites and set them to additive
Sprite A: Animated Sprite for Laser tail
Sprite B: Sprite for Body with only 1 texture on repeat mode, play with rect properties + animation player on rect to achieve the moving effect, don’t forget to check the rect flag before anything on sprite
Sprite C: Animated Sprite for laser head
Collision: Use raycast

I could make a more detailed post on this devblog:
when I achieve the alpha stage from my game.

Man this one is great. I had ideas in this direction but wasnt shure how to really do it. How do you manage the rotation of the start and end point sprites?

grol | 2016-03-27 17:38

Make the laser sprites child of another node with the pivot at the tail and apply the rotations to that node.

hearto | 2016-03-27 18:00

nice idea!
So, may I look at code of the raycast or maybe you could make a demo of this.
I would be very grateful for this!

JowannoSebastiano | 2016-06-01 08:30

Maybe the algorithm more explained:
Log In ‹ Kemono Games — WordPress

hearto | 2016-06-01 15:43

um… no, it didn’t :smiley:
I don’t understand how to make raycast collision

JowannoSebastiano | 2016-06-02 18:18