How to _draw(): curve.point_in/out handles

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

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

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!

:bust_in_silhouette: Reply From: njamster

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)

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!

Suleymanov | 2020-07-18 17:47