extends Node2D var cam var p1 var p2 var dist_max = 900 var zoom_rate = 0.001 func _ready(): cam = $Grid/Camera1 p1 = $Grid/Player1 p2 = $Grid/Player2 func _process(d): cam.position = 0.5 * (p1.position + p2.position) var dist = (p1.position).distance_to(p2.position) if dist < dist_max: cam.zoom = Vector2(1.0, 1.0) else: var zoom = 1.0 + (dist - dist_max) * zoom_rate cam.zoom = Vector2(zoom, zoom)