Camera fixes
This commit is contained in:
@@ -2,7 +2,13 @@ class_name CameraController extends Camera2D
|
||||
|
||||
|
||||
func apply_drag(delta: Vector2) -> void:
|
||||
position += delta / zoom
|
||||
var half_view: Vector2 = get_viewport_rect().size * 0.5 / zoom
|
||||
var min_pos := Vector2(limit_left, limit_top) + half_view
|
||||
var max_pos := Vector2(limit_right, limit_bottom) - half_view
|
||||
# Guard against maps smaller than the viewport (min > max)
|
||||
max_pos.x = max(min_pos.x, max_pos.x)
|
||||
max_pos.y = max(min_pos.y, max_pos.y)
|
||||
position = (position + delta / zoom).clamp(min_pos, max_pos)
|
||||
|
||||
|
||||
func set_map_bounds(rect: Rect2) -> void:
|
||||
|
||||
Reference in New Issue
Block a user