Hi I am following the godot docs tutorial for custom drawings and came up with this code for my project:
extends Node2D
var rotation_angle = 50
var nb_points : int = 32
var points_arc : PoolVector2Array = PoolVector2Array()
var angle_point : float
var center : Vector2
var radius : float
var angle_from : float = 90
var angle_to : float = 0
var color : Color
func _ready():
set_process(true)
func _draw():
center.y = 0
radius = abs(get_global_mouse_position().y)
print(radius)
center.x = radius
angle_to = 90
angle_from = 270
color = Color(1,0,0)
_draw_arc(center, radius, angle_from, angle_to, color)
func _process(delta):
update()
func _draw_arc(center, radius, angle_from, angle_to, color):
for i in range(nb_points + 1):
angle_point = deg2rad(angle_from + i * (angle_to - angle_from) / nb_points - 90)
points_arc.push_back(center + Vector2(cos(angle_point), sin(angle_point)) * radius)
for index_point in range(nb_points):
draw_line(points_arc[index_point], points_arc[index_point + 1], color)
what I want is to change the radius of the half circle drawn depending on my mouse pos y-coordinate I'm pretty sure the value for the radius is actually changing because by printing the value it is always different whenever I move my mouse but the half circle which is drawn is not updating although I am using update()
in the func _process()
and I used tool
at the beginning as well but doesn't seem to affect it at all
please help me resolve this thank you very much.