Advertisement
Guest User

Untitled

a guest
Aug 30th, 2020
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
GDB 1.09 KB | None | 0 0
  1. extends KinematicBody
  2.  
  3. onready var selectedUnits = []
  4.  
  5. # Stores the Vector3 points of our generated path
  6. var path = []
  7. # Stores which node in the path we are on
  8. var path_ind = 0
  9.  
  10. export var move_speed = 1
  11.  
  12. onready var nav = get_node("../../Navigation")
  13.  
  14. var move
  15.  
  16. var xlrate = .99
  17.  
  18. onready var cam = get_node("../../CamBase/Camera")
  19.  
  20. func Selected():
  21.     $PlayerMesh/SelectionShape.visible = true
  22.  
  23. func Deselected():
  24.     $PlayerMesh/SelectionShape.visible = false
  25.  
  26. func _physics_process(_delta):
  27.     if path_ind < path.size():
  28.         var move_vec = path[path_ind] - global_transform.origin
  29.         # The move vector (velocity towards desination) that is being produced lowers and then raises again causing the
  30.         # body to "stutter" the value should constantly reduce, not drop and then raise again
  31. #       print(move_vec.normalized())
  32.         if move_vec.length() < .08:
  33.             path_ind += 1
  34.         else:
  35.             var move = move_and_slide(move_vec.normalized() * move_speed)
  36.             print(move)
  37.             pass;
  38.            
  39. func move_to(target):
  40.         path = nav.get_simple_path(global_transform.origin, target, true)
  41.         path_ind = 0
  42.         print(path)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement