Guest User

unit

a guest
Mar 7th, 2019
1,850
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. extends KinematicBody
  2.  
  3. var path = []
  4. var path_ind = 0
  5. const move_speed = 12
  6. onready var nav = get_parent()
  7.  
  8. func _physics_process(delta):
  9. if path_ind < path.size():
  10. var move_vec = (path[path_ind] - global_transform.origin)
  11. if move_vec.length() < 0.1:
  12. path_ind += 1
  13. else:
  14. move_and_slide(move_vec.normalized() * move_speed, Vector3(0, 1, 0))
  15.  
  16. func move_to(target_pos):
  17. path = nav.get_simple_path(global_transform.origin, target_pos)
  18. path_ind = 0
Add Comment
Please, Sign In to add comment