0 votes

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!

Godot version Godot 3.5.1
in Engine by (17 points)
edited by

(edited the OP to fix code formatting)

1 Answer

0 votes
Best answer

This tutorial seems to be exactly what you're looking for...

by (19,268 points)
selected by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.