How to give a tendency to a camera on cursor?

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

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!

Been a week. Are you still here? I did this before, might post it later: Gunknown by Dlean Jeans

Dlean Jeans | 2019-06-30 07:19

:bust_in_silhouette: Reply From: ThreeSpark

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