2026-05-08 14:22:54 +00:00
|
|
|
extends Camera3D
|
|
|
|
|
|
2026-05-14 15:57:50 +00:00
|
|
|
@onready var game = get_parent()
|
|
|
|
|
@onready var camera_zones = game.get_node("CameraZones")
|
|
|
|
|
@onready var player = game.get_node("Player")
|
2026-05-08 14:22:54 +00:00
|
|
|
@onready var offset = position - player.position
|
2026-05-23 02:27:08 +00:00
|
|
|
var camera_point = null
|
2026-05-08 14:22:54 +00:00
|
|
|
|
|
|
|
|
func _ready() -> void:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
func _process(delta: float) -> void:
|
2026-05-16 18:05:49 +00:00
|
|
|
var goal_position = player.get_node("Collision").global_position + offset
|
|
|
|
|
|
|
|
|
|
global_position = lerp(global_position, goal_position, min(delta * 4, 1.0))
|
2026-05-14 15:57:50 +00:00
|
|
|
|
2026-05-23 02:27:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
if camera_point:
|
|
|
|
|
var origin = camera_point.global_transform.origin
|
|
|
|
|
var offset_from_camera_point = to_local(origin)
|
|
|
|
|
|
|
|
|
|
#print(offset_from_camera_point)
|
|
|
|
|
|
|
|
|
|
if (camera_point.max_distance_x.x != -INF) and (offset_from_camera_point.x < camera_point.max_distance_x.x):
|
|
|
|
|
var distance = offset_from_camera_point.x - camera_point.max_distance_x.x
|
|
|
|
|
|
|
|
|
|
global_position += camera_point.global_transform.basis * Vector3(distance, 0, 0)
|
|
|
|
|
|
|
|
|
|
if (camera_point.max_distance_x.y != INF) and (offset_from_camera_point.x > camera_point.max_distance_x.y):
|
|
|
|
|
var distance = offset_from_camera_point.x - camera_point.max_distance_x.y
|
|
|
|
|
|
|
|
|
|
global_position += camera_point.global_transform.basis * Vector3(distance, 0, 0)
|
|
|
|
|
|
2026-05-14 15:57:50 +00:00
|
|
|
for n in camera_zones.get_children():
|
|
|
|
|
if player in n.get_overlapping_bodies():
|
2026-05-23 02:27:08 +00:00
|
|
|
offset = n.get_node("Offset/Camera").global_position - n.get_node("Offset").global_position
|
|
|
|
|
n.get_node("Offset/Camera").look_at(n.get_node("Offset").global_position)
|
|
|
|
|
rotation = n.get_node("Offset/Camera").global_rotation
|
|
|
|
|
camera_point = n.get_node("Offset/Camera")
|