Advertisement
otorp2

smoothmovement

Nov 7th, 2015
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1.  
  2. extends Area2D
  3.  
  4. # member variables here, example:
  5. # var a=2
  6. # var b="textvar"
  7. const SPEED = 200
  8.  
  9.  
  10. func _ready():
  11. set_process(true)
  12.  
  13. pass
  14. func _process(delta):
  15.  
  16. var motion = Vector2()
  17. if Input.is_action_pressed("ui_up"):
  18. motion+=Vector2(0,-1)
  19. if Input.is_action_pressed("ui_down"):
  20. motion+=Vector2(0,1)
  21. if Input.is_action_pressed("ui_left"):
  22. motion+=Vector2(-1,0)
  23. if Input.is_action_pressed("ui_right"):
  24. motion+=Vector2(1,0)
  25. var pos = get_pos()
  26.  
  27. pos+=motion*delta*SPEED
  28. set_pos(pos)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement