i need to make so that if the mouse is to the right then my character will turn right.

Have you done stuff with other inputs? Using mouse buttons is no different from using any other button. Just set up your actions in the Input Map tab of Project Settings, and give them mouse button bindings.

When you want to start getting input in your script, (probably in your ready() function), you have to enable it with: set_process_input(true). Just like you have probably done with set_process(true), and the corresponding func process(delta):

func _input(event):
     if event.is_action_pressed("go_right"):
		do stuff . . . 
     elif event.is_action_pressed("go_left"):
          do opposite stuff . . . 

Or if you want to check it every frame, or whenever, you call Input.is_action_pressed("go_right"), which gives you a true or false value.

(wow i am way to vague with my questions) I need the screen to sense my mouse and to rotate my character in that direction thanks.......

Haha, ahh, yeah the "mouse button" in the title put me on the wrong track I guess.

From basically any node you can get_local_mouse_pos(), which gives you the relative position of the mouse from that node. I think that takes into account the node's rotation? If so, you can just check if get_local_mouse_pos().x > 0: add rotation, else: subtract rotation.

[Edit:] Yeah, you can just use the sign() of the mouse's local x and it's even simpler. These few lines make a sprite constantly follow your cursor around:

extends Sprite

var speed = 300
var rotspeed = 6

func _ready():
	set_process(true)

func _process(dt):
	rotate(rotspeed * dt * sign(get_local_mouse_pos().x))
	
	translate(get_transform().y * speed * dt)
6 years later