How to draw Rect2 in the center position of viewport
exs. Node2D func _ready(): rect() func rect(): var x = get_viewport().get_visible_rect().size.x/2 var y = get_viewport().get_visible_rect().size.y/2 var w = 20 var h = 20 #var position.middle = ?? rect = Rect2(x,y,20,20)
A draw_rect call will now draw a square of 20px in the middle of the viewport but the origin point is 0,0 of Node2D,in a default viewport of godot it draws the rectangle at 512y,300x but i want it to be 512-10y,300-10x but i dont want to put those values in there rather i would want to use w and h variables so what math and function should i do to make then x and y position - half of w and h ?