-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathChaseCamera.gd
More file actions
26 lines (20 loc) · 716 Bytes
/
ChaseCamera.gd
File metadata and controls
26 lines (20 loc) · 716 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
extends Camera
export var lerp_speed = 3.0
export (NodePath) var target_path = null
var target = null
var target_pos = null
var target_num = 0
func _ready():
if target_path:
target = get_node(target_path)
target_pos = target.get_node("CameraPositions").get_child(target_num)
func _physics_process(delta):
if !target:
return
global_transform = global_transform.interpolate_with(target_pos.global_transform, lerp_speed * delta)
func _input(event):
if event.is_action_pressed("change_camera"):
target_num = wrapi(target_num + 1, 0, target.get_node("CameraPositions").get_child_count())
target_pos = target.get_node("CameraPositions").get_child(target_num)
#func _on_change_camera(t):
# target = t