Initial commit.

This commit is contained in:
Patrick Marsee 2025-09-03 18:24:08 -04:00
commit 907695442f
28 changed files with 717 additions and 0 deletions

View file

@ -0,0 +1,37 @@
class_name FlightSimController
extends AircraftController
@export var pitch_down := &"pitch_down"
@export var pitch_up := &"pitch_up"
@export var yaw_left := &"yaw_left"
@export var yaw_right := &"yaw_right"
@export var roll_left := &"roll_left"
@export var roll_right := &"roll_right"
@export var throttle_down := &"throttle_down"
@export var throttle_up := &"throttle_up"
@export var pitch_speed := 1.0
@export var yaw_speed := 1.0
@export var roll_speed := 1.0
@export var throttle_speed := 1.0
func _physics_process(delta: float) -> void:
if get_multiplayer_authority() == multiplayer.get_unique_id():
var pitch_target := Input.get_axis(pitch_down, pitch_up)
var pitch_diff := pitch_target - pitch
pitch += signf(pitch_diff) * minf(absf(pitch_diff), pitch_speed * delta)
var yaw_target := Input.get_axis(yaw_left, yaw_right)
var yaw_diff := yaw_target - yaw
yaw += signf(yaw_diff) * minf(absf(yaw_diff), yaw_speed * delta)
var roll_target := Input.get_axis(roll_left, roll_right)
var roll_diff := roll_target - roll
roll += signf(roll_diff) * minf(absf(roll_diff), roll_speed * delta)
var throttle_target := Input.get_axis(throttle_down, throttle_up) * 0.5 + 0.5
if throttle_target > throttle:
throttle = minf(throttle_target, throttle + throttle_speed * delta)
elif throttle_target < throttle:
throttle = maxf(throttle_target, throttle - throttle_speed * delta)
brake = 1.0 if throttle < 0.05 else 0.0