Hello,
I'm looking for to make a system like we can see in RTS: when we move the mouse on a border of the window, the camera move to the direction of the mouse.
Here a code which works, BUT it works well only in windowed mode (1024 x 768), I need a "responsive" system (for fullscreen or for a larger size) and i don't find a way to make that.
I have tried to put area's and use them as borders but it's not effective when the windows isn't the same size than the camera.
onready var windoSize = OS.get_real_window_size()
# other code... #
func _input(event):
if event is InputEventMouseMotion:
var mousePos = get_viewport().get_mouse_position()
var normX = mousePos.x/windoSize.x
var normY = mousePos.y/windoSize.y
var XMove = false
var YMove = false
if normX < 0.05:
XMove = true
Input.set_custom_mouse_cursor(get_parent().scrollLeft, Input.CURSOR_ARROW, Vector2(16, 16))
camPlayer.camDir = Vector2.LEFT
elif normX > 3.7:
XMove = true
Input.set_custom_mouse_cursor(get_parent().scrollRight, Input.CURSOR_ARROW, Vector2(16, 16))
camPlayer.camDir = Vector2.RIGHT
else:
XMove = false
if not XMove and not YMove:
camPlayer.set_physics_process(false)
else:
camPlayer.set_physics_process(true)