Godot Version
Godot 4
Question
I created edge scrolling for the camera, but I don’t think it’s perfect because when the game is windowed, the camera moves even at the center of the game screen.
This is my code
var threshold = 10
var step = 50
func _process(delta):
edge_scrolling()
func edge_scrolling() :
var viewport_size = get_viewport().size
var local_mouse_pos = get_viewport().get_mouse_position()
if local_mouse_pos.x < threshold:
position.x -= step
elif local_mouse_pos.x > viewport_size.x - threshold:
position.x += step
if local_mouse_pos.y < threshold:
position.y -= step
elif local_mouse_pos.y > viewport_size.y - threshold:
position.y += step
I attached the script at remotetransform2d