my scene tree like that:

and script code here:
extends Node2D
var ball : Sprite2D
var trajectoryLine : Line2D
var rayCast : RayCast2D
var isDragging : bool = false
func _ready():
ball = $Ball
trajectoryLine = $TrajectoryLine
rayCast = $RayCast
# Connect signals
ball.connect("input_event", Callable(self, "_on_ball_input_event"))
rayCast.connect("input_event", Callable(self, "_on_ray_cast_input_event"))
func _process(delta: float):
if isDragging:
update_trajectory_line()
func _on_ball_input_event(viewport: Viewport, event: InputEvent, shape_idx: int):
if event is InputEventMouseButton and event.pressed:
isDragging = true
update_trajectory_line()
func _on_ray_cast_input_event(viewport: Viewport, event: InputEvent, shape_idx: int):
if event is InputEventMouseButton and event.pressed:
isDragging = false
trajectoryLine.clear_points() # Clear trajectory line when the click is released
func update_trajectory_line():
trajectoryLine.clear_points()
# Update the trajectory line based on the current mouse position
var mouse_position = get_viewport().get_mouse_position()
var direction = ball.global_position.direction_to(mouse_position)
var ray_length = ball.global_position.distance_to(mouse_position)
rayCast.cast_to = direction * ray_length
# Draw trajectory line points
trajectoryLine.add_point(ball.global_position)
trajectoryLine.add_point(rayCast.get_collision_point())
but when I click the ball, trajectory line not work, I dont know I missed, maybe I need draw something in Line2D or?