0 votes

Hello! I'm working on a 2D top-down game and recently stumbled upon a question: is there any way to reposition the camera after it have been "dragged" by moving to it's drag margins? I want player to move freely within current camera view, but if player has moved to the edge of screen, move camera to this side and then if player has stopped slowly align so that player is in center of screen. Right now camera is moving just fine (with drag margins) but after moving the camera player is kinda offset off center.

P.S: camera node set as child of player node

enter image description here

Thanks in advance!

Godot version 3.5
in Engine by (12 points)

1 Answer

0 votes

on the camera's _process() function:

if position != Vector2(0,0):

and then some code that steps you camara towards (0,0) such as:

position -= position.normalized()
if position.length() < 1: position = Vector2(0,0)
by (1,340 points)
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.