Topic was automatically imported from the old Question2Answer platform.
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?
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()