Pārlūkot izejas kodu

:wrench: Prevent discrete errors to propagate

See https://docs.godotengine.org/en/stable/tutorials/3d/using_transforms.html#precision-errors
DricomDragon 4 dienas atpakaļ
vecāks
revīzija
1b15a1ae7e
1 mainītis faili ar 3 papildinājumiem un 2 dzēšanām
  1. 3 2
      godot/component/entity/vehicles/biplan/biplan.gd

+ 3 - 2
godot/component/entity/vehicles/biplan/biplan.gd

@@ -15,7 +15,7 @@ var target_pitch: float = 0.0
 var target_rotation := Vector3.ZERO
 var target_thrust := Vector3.ZERO
 
-@onready var HorizontalFoil : Node3D = $HorizontalFoil
+@onready var VerticalFoil : Node3D = $VerticalFoil
 
 
 func trigger_thrust(activate: bool) -> void:
@@ -46,6 +46,7 @@ func _physics_process(_delta) -> void:
 	_apply_wing_resistance()
 	_apply_foil_resistance()
 	_apply_lift()
+	transform = transform.orthonormalized()
 
 
 func _apply_plane_rotation() -> void:
@@ -66,7 +67,7 @@ func _apply_wing_resistance() -> void:
 
 
 func _apply_foil_resistance() -> void:
-	var foil_position : Vector3 = HorizontalFoil.get_position()
+	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)