How do i stop the camera moving right when it should be moving left?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Boxx Ross

I’m setting up a camera system similar to something like nuclear throne, being able to peak the camera with the mouse, it works but the problem is that depending on where i put my cursor initially the camera moves in the wrong direction

positioning my cursor Right moves the camera Right

positioning my cursor Left moves the camera Right

positioning my cursor Up moves the camera Left

positioning my cursor Down moves the camera Left

positioning my cursor in the upper and lower right corners moves the camera up right and down right respectively

positioning my cursor in the lower and upper left Corners moves the camera up right and down right respectively

it seems to me that the camera has somehow rotated in such an odd way that I have no clue how to fix it, I’ve messed around with everything in the camera inspector, and I’ve found nothing. I do have a zooming system as well, but removing it fixes nothing.

here’s my camera code:

var spd = 10
var radius_req = 100
var timerss = 100
func _process(delta):
	var mouse_position = get_global_mouse_position()
	var mouse_delta = mouse_position - global_position
	if (mouse_delta.length() >= radius_req):
		if timerss != 0:
			self.position += (mouse_delta / radius_req) * spd * delta
			timerss = timerss - 1
	else:
		self.position = Vector2(0,0)
		timerss = 100

any help would be greatly appreciated!

(edited the OP to fix code formatting)

jgodfrey | 2023-01-05 19:01

:bust_in_silhouette: Reply From: jgodfrey

This tutorial seems to be exactly what you’re looking for…