-
Notifications
You must be signed in to change notification settings - Fork 1
/
Camera.gd
64 lines (48 loc) · 1.77 KB
/
Camera.gd
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# 99% stolen from
# https://kidscancode.org/godot_recipes/3d/interpolated_camera/
extends Camera
export var lerp_speed = 5.0
export var target_path = "/root/Main/BHOP_VISIBLE"
#export (Vector3) var offset = Vector3.ZERO
export (Vector3) var offset = Vector3(0,10,10)
onready var freecam = get_node("/root/Main/freecam/")
onready var mainnode = get_node("/root/Main/")
onready var FP = get_node("/root/Main/GoalPoint")
onready var BHOP_FUTURE = get_node("/root/Main/BHOP_FUTURE")
onready var Player = get_node("/root/Main/playable")
var target = null
var spawnpos
var freefly = false
func _ready():
current = true
spawnpos = global_transform.origin
if target_path:
target = get_node(target_path)
func _physics_process(delta):
if Input.is_action_just_pressed("freecam"):
cfg['camera_selected'] = "freecam"
freecam.head.get_node("Camera").current=true
# freecam.global_transform.origin= global_transform.origin
# freecam.head.rotation.x = rotation.x
# freecam.rotation.y = rotation.y
# freecam.rotation.z = rotation.z
if Input.is_action_just_pressed("playable"):
cfg['camera_selected'] = "playable"
Player.camera.current = true
if Input.is_action_just_pressed("follow"):
cfg['camera_selected'] = "follow"
current=true
# if cfg['freefly'] and !cfg['playable']:
# freecam.head.get_node("Camera").current=true
# freecam.global_transform.origin= global_transform.origin
# freecam.head.rotation.x = rotation.x
# freecam.rotation.y = rotation.y
# freecam.rotation.z = rotation.z
if !target:
return
else:
var target_pos = target.global_transform.translated(offset)
global_transform = global_transform.interpolate_with(target_pos, lerp_speed * delta)
look_at(target.global_transform.origin, Vector3.UP)
func reset():
global_transform.origin=spawnpos