Snake/camera_2d.gd

26 lines
623 B
GDScript3
Raw Normal View History

2025-08-08 15:02:44 +10:00
extends Camera2D
var target : Node2D
@export var temp_segment : Node2D
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
if (Input.is_action_just_pressed("test_switch_cam")):
if(target):
target = null
else:
target = temp_segment
if target:
2025-08-08 15:17:37 +10:00
# TODO FIX
position = lerp(position, target.position, 0.6 * delta)
zoom = lerp(zoom, Vector2(1,1),0.6 * delta)
2025-08-08 15:02:44 +10:00
else:
position = Vector2(0,0)
zoom = Vector2(0.05,0.05)