Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extends KinematicBody
- onready var selectedUnits = []
- # Stores the Vector3 points of our generated path
- var path = []
- # Stores which node in the path we are on
- var path_ind = 0
- export var move_speed = 1
- onready var nav = get_node("../../Navigation")
- var move
- var xlrate = .99
- onready var cam = get_node("../../CamBase/Camera")
- func Selected():
- $PlayerMesh/SelectionShape.visible = true
- func Deselected():
- $PlayerMesh/SelectionShape.visible = false
- func _physics_process(_delta):
- if path_ind < path.size():
- var move_vec = path[path_ind] - global_transform.origin
- # The move vector (velocity towards desination) that is being produced lowers and then raises again causing the
- # body to "stutter" the value should constantly reduce, not drop and then raise again
- # print(move_vec.normalized())
- if move_vec.length() < .08:
- path_ind += 1
- else:
- var move = move_and_slide(move_vec.normalized() * move_speed)
- print(move)
- pass;
- func move_to(target):
- path = nav.get_simple_path(global_transform.origin, target, true)
- path_ind = 0
- print(path)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement