Parcourir la source

:beetle: Fix foil resistance

AT LEAST !

> position is the offset from the body origin in global coordinates.

This piece of documentation means position is relative to the body ; but
in the global basis !

The force should be in the global basis as well.
DricomDragon il y a 2 mois
Parent
commit
41e63eaf4b
1 fichiers modifiés avec 7 ajouts et 4 suppressions
  1. 7 4
      godot/component/entity/vehicles/biplan/biplan.gd

+ 7 - 4
godot/component/entity/vehicles/biplan/biplan.gd

@@ -67,10 +67,13 @@ func _apply_wing_resistance() -> void:
 
 
 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
-	apply_force(local_foil_force, foil_position)
+	var horizontal_speed = linear_velocity.dot(transform.basis.x)
+	var local_foil_force = transform.basis.x * -foil_resistance * horizontal_speed
+
+	var foil_local_position: Vector3 = VerticalFoil.get_position()
+	var foil_global_offset: Vector3 = transform.basis * foil_local_position
+
+	apply_force(local_foil_force, foil_global_offset)
 
 
 func _apply_lift() -> void: