0 votes

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!

Godot version 3.2.3
in Engine by (276 points)

Please log in or register to answer this question.

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 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 webmaster@godotengine.org with your username.