Locking to mouse x

Godot Version

4.3.3

Question

how would i go about making a sprite lock onto the mouse x

think about it like going to mouse position but ignoring the y axis

You can add the following script to a Sprite2D and it will follow the mouse x position:

extends Sprite2D


func _process(delta: float) -> void:
	global_position.x = get_global_mouse_position().x