extends Camera2D

@onready var zoom_target : Vector2
@export var CameraCast : RayCast2D
@export var Player : CharacterBody2D

func _ready():
	zoom_target = zoom
	pass

func _process(delta):
	if CameraCast.is_colliding():
		self.position = lerp(self.position,CameraCast.get_collision_point(),4*delta)
	else:
		self.position = lerp(self.position,CameraCast.target_position + CameraCast.global_position,4*delta)
		pass
	_zoom(delta)

func _zoom(delta):
	if Input.is_action_just_pressed("camera_zoom_in"):
		zoom_target *= 1.1
	if Input.is_action_just_pressed("camera_zoom_out"):
		zoom_target *= 0.9
	zoom = zoom.slerp(zoom_target, 10 * delta)
