extends Control @export var camera_rect := Rect2() @onready var camera = %Camera2D as Camera2D var speed := 5 func display() -> void: visible = true # var current_camera = get_viewport().get_camera_2d() # current_camera.enabled = false camera.enabled = true camera.make_current() func _process(delta: float) -> void: if not is_visible_in_tree(): return # 镜头中心 -> 鼠标位置 var center_pos = camera.global_position + Vector2(282, 120) var direction = (camera.get_global_mouse_position() - center_pos).normalized() var target = camera_rect.get_support(direction) camera.position = camera.position.lerp(target, delta * speed)