added cam height change script
This commit is contained in:
28
Scripts/camera_Look.gd
Normal file
28
Scripts/camera_Look.gd
Normal file
@@ -0,0 +1,28 @@
|
||||
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
|
||||
|
||||
1
Scripts/camera_Look.gd.uid
Normal file
1
Scripts/camera_Look.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bnqpqdped5uw2
|
||||
Reference in New Issue
Block a user