Bezier Style Laser effect?

DacicusanDacicusan Posts: 7Member

I am trying to achieve this Bezier Style Laser effect, but in Godot and I have no clue how to do-it. Any help will be appreciated. Thank you.

A more advanced similar effect is that from Rochard, where the laser beam it is curved down when picking-up a heavy object. Rochard - Making of Video


  • TwistedTwiglegTwistedTwigleg Posts: 3,525Admin

    I have not tried it myself, but you probably need to generate a Bezier curve between three points in Godot, there is a page on the documentation that might be helpful for this. Once you have the curve, you should just need to then create a mesh that follows that curve.

    The hard part might be calculating the middle point, since it needs to form a triangle. You could try something like this, which might work (based on code from the documentation, untested):

    func _get_bezier_position_from_two_points(point_one: Vector3, point_two: Vector3, point_on_curve: float):
        var point_middle = ((point_one + point_two) / 2)
        # Add some distance to the middle point so all three points form a triangle
        var point_middle_height = 0.75
        point_middle += (Vector3.UP * point_middle_height)
        var q0 = point_one.linear_interpolate(point_middle, point_on_curve)
        var q1 = point_middle.linear_interpolate(point_two, point_on_curve)
        var result = q0.linear_interpolate(q1, point_on_curve)
        return result

    And then you could use these points, in theory at least, with something like an ImmediateGeometry node. The documentation has a page showing how to generate a triangle with the ImmediateGeometry node. You might be able to use PRIMITIVE LINES as the mesh type, which might make it easier to draw the Bezier curve.

    Hopefully this helps a bit! It looks like it is doable in Godot, but it might take some trial and error to find a solution.

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file