0 votes

I need Path2D visible and modifiable in Play Mode. Here is the script that works perfectly well:

func _draw():

if curve.get_point_count() > 0:
    draw_polyline(curve.get_baked_points(), Color.white, 2)
for p in curve.get_point_count():
    var pos = curve.get_point_position(p) 
    draw_circle(pos, 5, Color.white)
if (currentTool == tools.SELECT or currentTool == tools.MOVE):   
    draw_circle(curve.get_point_position(index), 8 , Color.red)

So far, so good. But when I add bezier in/out handles under _draw() function it returns error:

    draw_circle(curve.get_point_in(), 10 , Color.orange)
    draw_circle(curve.get_point_out(), 10 , Color.orange)

Apparently, I'm doing something wrong, do you have any idea what should be done for it to draw handles for me? What should be added and how? Highly appreciate your time and attention!

in Engine by (327 points)

1 Answer

+1 vote
Best answer

But when I add bezier in/out handles [...] it returns error

If Godot returns an error, you...

  1. ... read it & try to understand the problem yourself and...
  2. ... if you don't understand it, you post it here along with your question

Otherwise I have to run your code myself just to see the error message... Which in this case clearly states the problem: Too few arguments for "get_point_in()" call. Expected at least 1. So all you have to do is provide an argument, specifying the id of the point you want to draw the in/out-handles for, e.g. for the first point it's:

   draw_circle(curve.get_point_in(0), 10 , Color.orange)
   draw_circle(curve.get_point_out(0), 10 , Color.orange)
by (10,469 points)
selected by

Sorry, you had to run the code to get the error, next time I ask questions I'll attach the error message. And thank you for your help! It worked, and I replaced it with p to meet my needs. Highly appreciated!

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.