Advertisement
placek

Untitled

May 31st, 2020
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. extends KinematicBody2D
  2.  
  3. export (int) var speed = 200
  4.  
  5. var target = Vector2()
  6. var velocity = Vector2()
  7.  
  8. func _input(event):
  9. if event.is_action_pressed('click'):
  10. target = get_global_mouse_position()
  11.  
  12. func _physics_process(delta):
  13. velocity = position.direction_to(target) * speed
  14. if position.distance_to(target) > 5:
  15. velocity = move_and_slide(velocity)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement