- Edited
I want my camera2d to move to the right or left if you move your cursor to the edge of the screen. My current code is this:
extends Camera2D
var spd = 10
func _process(delta):
var mouse = get_viewport().get_mouse_position()
if mouse.x > 0 and mouse.y > 0 and mouse.x < 100 and mouse.y < 600:
position.x -= spd
elif mouse.x > 924 and mouse.y > 0 and mouse.x < 1024 and mouse.y < 600:
position.x += spd
This works but it isn't the best because it suddenly jumps when you go into the movement range whereas I would like it if the closer to the edge of the screen the cursor is the faster the screen moves.
Thanks.