Help with HUD moving element

Godot Version

4.1.1

Question

Hello there, I wanted to make an node that can show the time on my HUD. But instead of time I want it to only show a sun and a moon. My idea was to have a half a circle and the sun to move in an arch during the day and just as it disapears off at the end the moon to start doing that. Now I thought off a few ways and did a few experiments but there was always something missing. the node is TimeUI which is added as a child of the HUD. It only has a sun and a moon on that node so nothing more. The first try was to make it as a texture progress bar thinking it would work but it only went as the name say progress bar. Next I tried with a Path2d but since thats a not a control node it follows the world and it was off screen. Any suggestions on how can I pull this of?

You can do this with a bit of vector mathematics. Explaining the entire field of vector mathematics goes a bit too far for a post on a message board - it is something I took an entire course in during my college days - so I suggest searching for more information on the internet.

I did bang out this bit of code for you which should give a nudge in the right direction, but please note it does not meet all of the requirements as you laid out.

extends Control

@export var symbol : TextureRect = null
@export var center_graphic : TextureRect = null
@export var center_point : Vector2 = Vector2(200, 0)
@export var clock_hand : Vector2 = Vector2.RIGHT
@export var hand_length : float = 300.0
@export var timer : Timer = null
@export var number_of_ticks : int = 0
const MAX_TICKS : int = 59

func _ready() -> void:
	center_graphic.position = center_point
	symbol.position = (Vector2.RIGHT * hand_length) + center_point
	timer.timeout.connect(_on_timeout.bind())

func _on_timeout()->void:
	clock_hand = Vector2.RIGHT.rotated(deg_to_rad((float(number_of_ticks) * 6.0))).normalized()
	print(clock_hand)
	symbol.position = (clock_hand * hand_length) + center_point
	number_of_ticks += 1
	
	if number_of_ticks == MAX_TICKS - 1:
		number_of_ticks = 0

Add a new scene that inherits from Control and add the code as a script. Then add two TextureRects as children and give both a Texture. Also add a Timer that fires once every second and check the Autostart box in the inspector. Press F6 to run the scene. You should get something like this:

Thank You, I will surely read about this in a bit more detail and try to see if I can implement something similar.