Topic was automatically imported from the old Question2Answer platform.
Asked By
jim
Hello everyone! Im developing a 2D rogue-like game and came up with the following predicament:
Im doing a weapon that shoots a laser-like beam that attaches itself to either the second player or the enemy (Both KinematicBodies here), and keep both ends connected while doing damage to whatever comes in contact with it and has a certain tag (enemies). The player and enemies can move, so the line has to acompany that movement (might change either direction, distance, etc…)
…That was the plan, but i have no idea on how to approach this. In Unity i suppose i could use Line Renderer to put a texture on the line, and work via code with two Vector2 positions to apply damage and conect the line begining and end. Is that possible in Godot?
I know about the Draw() function, but a simple line with solid color is not exactly what i am lookin for here. Maybe a particle emmiter in order to produce the lightning effect?
Does anybody have a suggestion…? Thanks in advance!
Godot has a “line” tool for this if it is 2D. The line tool also takes textures.
If it is 3D then you will have to make your own tool. Stretching a polygon for the effect would be the quickest way.
Yeah I’ve found about the Line2D node later (the project is 2D), but its my understanding that the line just uses a static Texture? I was also lookin into a way of adding noise to it (be it lightning, laser beam, anything). Another user suggested using Shaders. Will look into it, but if anybody got any more references, I would certainly welcome it.
Thanks man!
jim | 2018-09-13 19:43
Also, the Line2D tool doesnt have a collision inner working, so I would guess i need to make instances of Area2D nodes that accompany each Vector2 along the Line2D that do the damage…? or is there an easier way of implementing this?
jim | 2018-09-13 19:46
A raycast would be faster. Check from point to point or from start to end.
Awesome! yesterday I’ve found a similar implementation of this shader (Using Texture Rect), but when i tried applying it to the Line2D node, something went wrong… I’ve got no experience working with shaders, so maybe i need to research this some more. Dont know if there is a more specific way to implement this on a line that I’m missing.