get_point_in(), get_point_out positioned oddly.

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

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)
    update()

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?

Images of the problem:

https://ibb.co/kB21hcW

https://ibb.co/LZz521W

Suleymanov | 2021-04-12 19:55

:bust_in_silhouette: Reply From: Suleymanov

SOLVED!

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)
    update()