123456789101112131415161718192021 |
- extends Node2D
- onready var cam = $Grid/Camera1
- var player = []
- var dist_max = 900
- var zoom_rate = 0.001
- func _ready():
- player.append($Grid/Player1)
- player.append($Grid/Player2)
- func _process(d):
- cam.position = 0.5 * (player[0].position + player[1].position)
- var dist = (player[0].position).distance_to(player[1].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)
|