Advertisement
otorp2

rot2

Oct 13th, 2015
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1.  
  2. extends Node2D
  3.  
  4. # member variables here, example:
  5. # var a=2
  6. # var b="textvar"
  7.  
  8. func _ready():
  9. set_fixed_process(true)
  10.  
  11. # Initialization here
  12. pass
  13. func _fixed_process(delta):
  14. var min_degrees = -1.5
  15. var max_degrees = 1.5
  16. var speed = 150
  17. #var dir = Vector2(0,0)
  18. var rot = get_node("player").get_rot()
  19.  
  20. if Input.is_action_pressed("ui_left"):
  21. rot -= deg2rad( 120 * delta )
  22. if Input.is_action_pressed("ui_right"):
  23. rot += deg2rad( 120 * delta )# rotate 120 degrees / second
  24.  
  25. if rot < min_degrees:
  26. rot = min_degrees
  27. if rot > max_degrees:
  28. rot = max_degrees
  29. get_node("player").set_rot(rot)
  30.  
  31. print(rad2deg(rot))
  32.  
  33. pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement