initial commit
This commit is contained in:
commit
79951d8075
22 changed files with 729 additions and 0 deletions
34
player/camera_gimbal.gd
Normal file
34
player/camera_gimbal.gd
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
class_name CameraGimbal extends Node3D
|
||||
|
||||
@export var rotation_speed = (PI / 180) * 120
|
||||
|
||||
func reset():
|
||||
basis = Basis()
|
||||
$InnerGimbal.basis = Basis()
|
||||
|
||||
func rotate_camera_y(y, delta):
|
||||
rotate_object_local(Vector3.UP, y * rotation_speed * delta)
|
||||
func rotate_camera_x(x, delta):
|
||||
$InnerGimbal.rotate_object_local(
|
||||
Vector3.RIGHT, x * rotation_speed * delta)
|
||||
|
||||
func _process(delta):
|
||||
# rotate outer gimbal around y axis
|
||||
var y = 0
|
||||
if Input.is_action_pressed("cam_left"):
|
||||
y += 1
|
||||
if Input.is_action_pressed("cam_right"):
|
||||
y -= 1
|
||||
rotate_camera_y(y, delta)
|
||||
|
||||
# rotate inner gimbal around x axis
|
||||
var x = 0
|
||||
if Input.is_action_pressed("cam_up"):
|
||||
x -= 1
|
||||
if Input.is_action_pressed("cam_down"):
|
||||
x += 1
|
||||
rotate_camera_x(x, delta)
|
||||
|
||||
# reset gimbals
|
||||
if Input.is_action_pressed("cam_reset"):
|
||||
reset()
|
||||
Loading…
Add table
Add a link
Reference in a new issue