+1 vote

Hello Godot-Community!

I want to make a camera to have a light tendency to a cursor like
in the game "Forager". (https://www.youtube.com/watch?v=lpOP2KFBa5E)
Thank you!

in Engine by (160 points)

Been a week. Are you still here? I did this before, might post it later: https://dleanjeans.itch.io/gunknown

1 Answer

+1 vote
Best answer

well the most simple version would be something like

var mpos
var cam_offset_divider = 8 #this is just my personal preference, it can be whatever you want

func _process(delta):
mpos = get_global_mouse_position() #could be get_global_mouse_position() or get_local_mouse_position, it's really your choice - each behaves in its own way. Just don't do get_viewport().get_mouse_position() because that calls the mouse position in the viewport rather than in the computer
$Camera2D.offset = mpos / cam_offset_divider
by (124 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 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 webmaster@godotengine.org with your username.