37 lines
1.2 KiB
GDScript
37 lines
1.2 KiB
GDScript
extends Camera3D
|
|
|
|
var height_target = position.y
|
|
const CHANGE_AMT_ON_SCROLL = 4.0
|
|
const CAM_CHANGE_SPEED = 4.0
|
|
var MAX_CAM_HEIGHT = position.y + CHANGE_AMT_ON_SCROLL
|
|
var MIN_CAM_HEIGHT = position.y - (CHANGE_AMT_ON_SCROLL * 2)
|
|
|
|
@onready var target = get_parent()
|
|
|
|
func _process(delta: float) -> void:
|
|
look_at(get_parent().global_position,Vector3.UP)
|
|
|
|
camera_fov()
|
|
camera_height_change(delta)
|
|
|
|
func camera_fov():
|
|
var distance_to_target = global_position.distance_to(target.global_position)
|
|
attributes.dof_blur_far_distance = distance_to_target + 15.0
|
|
attributes.dof_blur_near_distance = distance_to_target - 3
|
|
|
|
func camera_height_change(delta):
|
|
#if global_position.y == height_target:
|
|
if Input.is_action_just_pressed("scroll_up"):
|
|
height_target = clamp(height_target - CHANGE_AMT_ON_SCROLL,MIN_CAM_HEIGHT,MAX_CAM_HEIGHT)
|
|
|
|
if Input.is_action_just_pressed("scroll_down"):
|
|
height_target = clamp(height_target + CHANGE_AMT_ON_SCROLL,MIN_CAM_HEIGHT,MAX_CAM_HEIGHT)
|
|
|
|
global_position.y = lerp(global_position.y,height_target,delta * CAM_CHANGE_SPEED)
|
|
#else:
|
|
#var direction_to_target = global_position.y - height_target
|
|
#var move_amount = direction_to_target * delta * CAM_CHANGE_SPEED
|
|
#global_position.y += move_amount
|
|
#height_target -= move_amount
|
|
|