4 Incheckningar fd3494e2e1 ... d24fc04c38

Upphovsman SHA1 Meddelande Datum
  DricomDragon d24fc04c38 :wrench: Mega damp 2 dagar sedan
  DricomDragon 06394203e9 Add physics reaction monitors 4 dagar sedan
  DricomDragon 61657acf68 :wrench: Add command monitors 4 dagar sedan
  DricomDragon 7bc804a344 :wrench: Slightly reduce lift 4 dagar sedan

+ 33 - 9
godot/component/entity/vehicles/biplan/biplan.gd

@@ -4,20 +4,44 @@ extends SeatedVehicle
 const PLANE_FORWARD := Vector3.BACK # z increases when moving forward
 
 @export var thrust_power: float = 3500.0
-@export var turn_to_torque: float = 1000.0
-@export var move_to_pitch: float = 2000.0
+@export var turn_to_torque: float = 10000.0
+@export var move_to_pitch: float = 20000.0
 @export var wing_resistance: float = 2500.0
-@export var foil_resistance: float = 250.0
-@export var lift: float = 50.0
+@export var foil_resistance: float = 500.0
+@export var lift: float = 25.0
 
 var target_torque: float = 0.0
 var target_pitch: float = 0.0
 var target_rotation := Vector3.ZERO
 var target_thrust := Vector3.ZERO
 
+# Physics logs
+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
 
 
+func _register_custom_monitors() -> void:
+	Performance.add_custom_monitor("plane/torque", func(): return abs(target_torque))
+	Performance.add_custom_monitor("plane/pitch", func(): return abs(target_pitch))
+	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()
+
+
 func trigger_thrust(activate: bool) -> void:
 	if activate:
 		target_thrust = PLANE_FORWARD * thrust_power
@@ -60,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)
 
 
@@ -77,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)
 

+ 1 - 0
godot/component/entity/vehicles/biplan/biplan.tscn

@@ -28,6 +28,7 @@ collision_mask = 27
 mass = 500.0
 contact_monitor = true
 max_contacts_reported = 1
+angular_damp = 30.0
 script = ExtResource("1_vi3fj")
 
 [node name="TheWindWaker_noWheel" parent="." instance=ExtResource("2_mr41j")]