Head of character following mouse 2D

Godot Version

4.7 Stable

Question

I’m trying to make it so then the head of my character will face the mouse at all times, can someone help me?

func _ready() -> void:
	$Head.rotation = get_global_mouse_position().direction_to($Head.rotation)

This is what I have so far but I’m not sure how to do soemthing like this.

you want the angle from the head to the mouse position

func _ready() -> void:
    $Head.rotation = $Head.global_position.angle_to(get_global_mouse_position())

Or simplify this by using look_at

func _ready() -> void:
    $Head.look_at(get_global_mouse_position())

Under _ready this will only happen once, at the very start of the game, so it’s not particularly useful with _ready, maybe you mean to use _process?

Thank you for helping me out.