mirror of
https://github.com/godotengine/godot-docs.git
synced 2026-01-05 22:09:56 +03:00
Modify code adaptation 4.0 physics_introduction
Modify code adaptation 4.0 physics_introduction
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user