|
@@ -16,11 +16,11 @@ var target_rotation := Vector3.ZERO
|
|
|
var target_thrust := Vector3.ZERO
|
|
|
|
|
|
# Physics logs
|
|
|
-var last_forward_velocity: float = 0.0
|
|
|
-var last_slide_velocity: float = 0.0
|
|
|
-var last_lift: float = 0.0
|
|
|
-var last_wing_resistance: float = 0.0
|
|
|
-var last_foil_resistance: float = 0.0
|
|
|
+var vertical_speed: float = 0.0
|
|
|
+var horizontal_speed: float = 0.0
|
|
|
+var local_wing_force := Vector3.ZERO
|
|
|
+var local_foil_force := Vector3.ZERO
|
|
|
+var local_lift_force := Vector3.ZERO
|
|
|
|
|
|
@onready var VerticalFoil : Node3D = $VerticalFoil
|
|
|
|
|
@@ -31,6 +31,12 @@ func _register_custom_monitors() -> void:
|
|
|
Performance.add_custom_monitor("plane/rotation", func(): return target_rotation.length())
|
|
|
Performance.add_custom_monitor("plane/thrust", func(): return target_thrust.length())
|
|
|
|
|
|
+ Performance.add_custom_monitor("plane/vertical_speed", func(): return abs(vertical_speed))
|
|
|
+ Performance.add_custom_monitor("plane/horizontal_speed", func(): return abs(horizontal_speed))
|
|
|
+ Performance.add_custom_monitor("plane/wing_force", func(): return local_wing_force.length())
|
|
|
+ Performance.add_custom_monitor("plane/foil_force", func(): return local_foil_force.length())
|
|
|
+ Performance.add_custom_monitor("plane/lift_force", func(): return local_lift_force.length())
|
|
|
+
|
|
|
|
|
|
func _ready() -> void:
|
|
|
_register_custom_monitors()
|
|
@@ -78,16 +84,16 @@ func _apply_plane_thrust() -> void:
|
|
|
|
|
|
|
|
|
func _apply_wing_resistance() -> void:
|
|
|
- var vertical_speed = linear_velocity.dot(transform.basis * Vector3.UP)
|
|
|
- var local_wing_force = Vector3.UP * -wing_resistance * vertical_speed
|
|
|
+ vertical_speed = linear_velocity.dot(transform.basis * Vector3.UP)
|
|
|
+ local_wing_force = Vector3.UP * -wing_resistance * vertical_speed
|
|
|
var wing_force = transform.basis * local_wing_force
|
|
|
apply_central_force(wing_force)
|
|
|
|
|
|
|
|
|
func _apply_foil_resistance() -> void:
|
|
|
var foil_position : Vector3 = VerticalFoil.get_position()
|
|
|
- var horizontal_speed = linear_velocity.dot(transform.basis * Vector3.RIGHT)
|
|
|
- var local_foil_force = Vector3.RIGHT * -foil_resistance * horizontal_speed
|
|
|
+ horizontal_speed = linear_velocity.dot(transform.basis * Vector3.RIGHT)
|
|
|
+ local_foil_force = Vector3.RIGHT * -foil_resistance * horizontal_speed
|
|
|
apply_force(local_foil_force, foil_position)
|
|
|
|
|
|
|
|
@@ -95,7 +101,7 @@ func _apply_lift() -> void:
|
|
|
var forward_speed = linear_velocity.dot(transform.basis * PLANE_FORWARD)
|
|
|
if forward_speed < 0.0 :
|
|
|
forward_speed = 0.0
|
|
|
- var local_lift_force = Vector3.UP * lift * forward_speed
|
|
|
+ local_lift_force = Vector3.UP * lift * forward_speed
|
|
|
var lift_force = transform.basis * local_lift_force
|
|
|
apply_central_force(lift_force)
|
|
|
|