Browse Source

Modify code adaptation 4.0 physics_introduction

Modify code adaptation 4.0 physics_introduction
kkoang 2 years ago
parent
commit
6f1977f821
1 changed files with 6 additions and 6 deletions
  1. 6 6
      tutorials/physics/physics_introduction.rst

+ 6 - 6
tutorials/physics/physics_introduction.rst

@@ -263,15 +263,15 @@ For example, here is the code for an "Asteroids" style spaceship:
 
 
     func _integrate_forces(state):
     func _integrate_forces(state):
         if Input.is_action_pressed("ui_up"):
         if Input.is_action_pressed("ui_up"):
-            applied_force = thrust.rotated(rotation)
+            state.apply_force(thrust.rotated(rotation))
         else:
         else:
-            applied_force = Vector2()
-        var rotation_dir = 0
+            state.apply_force(Vector2())
+        var rotation_direction = 0
         if Input.is_action_pressed("ui_right"):
         if Input.is_action_pressed("ui_right"):
-            rotation_dir += 1
+            rotation_direction += 1
         if Input.is_action_pressed("ui_left"):
         if Input.is_action_pressed("ui_left"):
-            rotation_dir -= 1
-        applied_torque = rotation_dir * torque
+            rotation_direction -= 1
+        state.apply_torque(rotation_direction * torque)
 
 
  .. code-tab:: csharp
  .. code-tab:: csharp