29 lines
951 B
GDScript
29 lines
951 B
GDScript
extends Camera3D
|
|
|
|
var height_target = position.y
|
|
const CHANGE_AMT_ON_SCROLL = 4.0
|
|
const CAM_CHANGE_SPEED = 2.0
|
|
var MAX_CAM_HEIGHT = position.y + CHANGE_AMT_ON_SCROLL
|
|
var MIN_CAM_HEIGHT = position.y - (CHANGE_AMT_ON_SCROLL * 2)
|
|
|
|
func _process(delta: float) -> void:
|
|
look_at(get_parent().global_position,Vector3.UP)
|
|
|
|
camera_height_change(delta)
|
|
|
|
func camera_height_change(delta):
|
|
#if global_position.y == height_target:
|
|
if Input.is_action_just_pressed("scroll_down"):
|
|
height_target = clamp(height_target - CHANGE_AMT_ON_SCROLL,MIN_CAM_HEIGHT,MAX_CAM_HEIGHT)
|
|
|
|
if Input.is_action_just_pressed("scroll_up"):
|
|
height_target = clamp(height_target + CHANGE_AMT_ON_SCROLL,MIN_CAM_HEIGHT,MAX_CAM_HEIGHT)
|
|
|
|
global_position.y = height_target
|
|
#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
|
|
|