Open bojidar-bg opened 8 years ago
The camera should be moved when the cursor goes near the edge of the screen (RTS style).
Sample code:
var camera_move = Vector2(0,0) #...Other ways to move the camera... var mouse_move = (get_global_mouse_pos() - camera.get_global_pos()) / get_viewport_rect().size * get_viewport_transform().get_scale() * 2 var mouse_distance = max(abs(mouse_move.x), abs(mouse_move.y)) if mouse_distance > 0.9: camera_move += mouse_move camera.set_pos(camera.get_pos() + camera_move * camera_speed * delta )
The camera should be moved when the cursor goes near the edge of the screen (RTS style).
Sample code: