|
@@ -4,12 +4,15 @@ extends RigidBody2D
|
|
|
|
|
|
|
|
|
const THRUST_STRENGTH = 400_000
|
|
|
+const TORQUE_THRUST = 1
|
|
|
|
|
|
-var current_force = Vector2.ZERO
|
|
|
+var current_force := Vector2.ZERO
|
|
|
+var current_torque : float = 0.0
|
|
|
|
|
|
|
|
|
func _physics_process(delta):
|
|
|
apply_central_force(current_force)
|
|
|
+ apply_torque(current_torque)
|
|
|
|
|
|
|
|
|
func _on_command(dir: Vector2) -> void:
|
|
@@ -17,4 +20,5 @@ func _on_command(dir: Vector2) -> void:
|
|
|
|
|
|
|
|
|
func _thrust(dir: Vector2) -> void:
|
|
|
- current_force = dir * THRUST_STRENGTH
|
|
|
+ current_force = Vector2.UP * dir.y * THRUST_STRENGTH
|
|
|
+ current_torque = dir.x * TORQUE_THRUST * THRUST_STRENGTH
|