How can I make my character rotate left or right towards my curser

Godot Version

GDOT 4.2.1

Question

How can I make my character rotate left or right towards my curser like terraria? I am new so try go easy.

use .look_at( get_global_mouse_position())
put it at func _physics_process():

Ive seen this before but I want something where I follow the curser but only left and right.

func _unhandled_input(event):
	if event is InputEventMouseButton:
		if event.button_index==MOUSE_BUTTON_LEFT and event.is_pressed():
			var side=get_global_mouse_position().x-$Sprite2D.global_position.x
			if side>=global_position.x:
				$Sprite2D.flip_h=false
			else:
				$Sprite2D.flip_h=true

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.