blob: feb5ad2b762a253fb4a717b31af015071b424f83 (
plain) (
tree)
|
|
extends RigidBody
export var ang_acceleration = 240.0
onready var player_cam_pivot = $"fps_controller"
onready var player_cam = player_cam_pivot.get_node("Camera")
onready var ship_cam_pivot = $"CameraPivot"
onready var ship_cam = ship_cam_pivot.get_node("Camera")
func lock_camera_to_boat():
player_cam_pivot.global_transform.basis = Basis(Vector3.UP*player_cam_pivot.global_transform.basis.get_euler().y)
ship_cam_pivot.global_transform.basis = Basis(Vector3.UP*ship_cam_pivot.global_transform.basis.get_euler().y)
func _physics_process(_delta):
if Input.is_action_just_pressed("camera_swap"):
if ship_cam.current:
player_cam.current = true
else:
ship_cam.current = true
lock_camera_to_boat()
func _input(event):
if event is InputEventMouseMotion:
ship_cam.rotation.x += -event.relative.y * Settings.mouse_sens
ship_cam.rotation.x = clamp(ship_cam.rotation.x, -1.2, 1.2)
ship_cam.rotation.y += -event.relative.x * Settings.mouse_sens
ship_cam.rotation.y = wrapf(ship_cam.rotation.y, 0, TAU)
func _integrate_forces(_state):
var stick = Input.get_axis("ship_right","ship_left")
if stick != 0.0:
self.add_torque(Vector3.UP*stick*ang_acceleration)
|