Advertisement
Guest User

Untitled

a guest
Jul 2nd, 2020
686
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. extends RigidBody
  2.  
  3. const Z_FRONT = -1 #in this game the front side is towards negative Z
  4. const THRUST_Z = 2000
  5. const THRUST_TURN = 3200
  6.  
  7. onready var leftEngineParticles = $ParticlesLeftEngine
  8. onready var rightEngineParticles = $ParticlesRightEngine
  9.  
  10. var wasThrust = false #particles enabled?
  11.  
  12. # damping: see linear and angular damping parameters
  13.  
  14. func _physics_process(delta):
  15. if Input.is_action_pressed("ui_accept"):
  16. add_central_force(transform.basis.z * Z_FRONT * THRUST_Z)
  17. if !wasThrust:
  18. wasThrust = true
  19. leftEngineParticles.emitting=true
  20. rightEngineParticles.emitting=true
  21. else:
  22. if wasThrust:
  23. wasThrust=false
  24. leftEngineParticles.emitting=false
  25. rightEngineParticles.emitting=false
  26.  
  27. if Input.is_action_pressed("ui_down"): #dive up
  28. add_torque(global_transform.basis.x * -THRUST_TURN * Z_FRONT)
  29. if Input.is_action_pressed("ui_up"): #dive down
  30. add_torque(global_transform.basis.x * THRUST_TURN * Z_FRONT)
  31. if Input.is_action_pressed("ui_left"):
  32. add_torque(global_transform.basis.z * -THRUST_TURN * Z_FRONT)
  33. if Input.is_action_pressed("ui_right"):
  34. add_torque(global_transform.basis.z * THRUST_TURN * Z_FRONT)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement