Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Suleymanov |
Currently I can successfully draw circles and lines to make the Path curve visible in play mode. I can also move around the control points of the curve in play mode. But I can’t access the handles of the control points to fine tune them. My question is, how can I access the handles of the control points so that I can both control them and make them visible?
Currently my code is as below:
var idx = 0
var path = get_node("Path2D")
#INPUT
func _input(event):
if event is InputEventScreenTouch and event.pressed:
#SELECT POINTS
for p in path.curve.get_point_count():
if path.curve.get_point_position(p).distance_to(event.position) < 40:
idx = p
update()
if event is InputEventScreenDrag:
#DRAG POINTS
for p in path.curve.get_point_count():
if path.curve.get_point_position(p).distance_to(event.position) < 40:
path.curve.set_point_position(idx, path.curve.get_point_position(idx) + event.relative)
update()
#DRAW
func _draw():
draw_polyline(path.curve.get_baked_points(), c, 2, true)
for p in path.curve.get_point_count():
draw_circle(path.curve.get_point_position(p), 8, c)
update()
The above code works well. I would appreciate any idea how I can add handles to the equation. Handles also have following options: “Mirror Handle Angles”, “Mirror Handle Lengths”. Would be useful to be able to control them in the script too.
Thank you for your time!