Bläddra i källkod

Modify code adaptation 4.0 physics_introduction

Modify code adaptation 4.0 physics_introduction
kkoang 2 år sedan
förälder
incheckning
6f1977f821
1 ändrade filer med 6 tillägg och 6 borttagningar
  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):
         if Input.is_action_pressed("ui_up"):
-            applied_force = thrust.rotated(rotation)
+            state.apply_force(thrust.rotated(rotation))
         else:
-            applied_force = Vector2()
-        var rotation_dir = 0
+            state.apply_force(Vector2())
+        var rotation_direction = 0
         if Input.is_action_pressed("ui_right"):
-            rotation_dir += 1
+            rotation_direction += 1
         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