0 votes

Trying to draw circle on curve Handles by:

func _draw():
    for p in path.curve.get_point_count():
        draw_circle($Path.curve.get_point_in(p), 5, white)
        draw_circle($Path.curve.get_point_out(p), 5, white)

It draws as intended but anywhere except where the Handles should be. They are in random places without correlation. How to make it draw in exact spot of Handles?

Godot version 3.2.3
in Engine by (335 points)

1 Answer

0 votes
Best answer


The problem was get_point_in() and get_point_out() gave local position relative to each control point. So, get_point_position() - get_point_in() solved it. In case somebody needs code, here you go:

func _draw():
    draw_polyline($Path.curve.get_baked_points(), white, 2, true)
    for p in $Path.curve.get_point_count():
         draw_circle($Path.curve.get_point_position(p), 8, white)
         draw_circle($Path.curve.get_point_position(p) - $Path.curve.get_point_in(p), 8, white)
         draw_circle($Path.curve.get_point_position(p) - $Path.curve.get_point_out(p), 8, white)
         var a = $Path.curve.get_point_position(p) - $Path.curve.get_point_in(p)
         var b = $Path.curve.get_point_position(p) - $Path.curve.get_point_out(p)
         draw_polyline(PoolVector2Array([a, b]), white, 2, true)
by (335 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.