Few things with Godot built in 2d navigation.
- They keep getting stuck on other units going to the same place than wont move to a new position until they reach first their position.
- they seem to take a weird path/no optimal I made sure my navigation 2d was not the problem they are well within it
my code:
func ready():
animationplayer.play("walking")
Destination = WorldPOS.castleposition
Master.position = Vector2(1200, 300)
path = Navpoly.getsimplepath(globalposition, Nav.soldierdes, false)
func _physics_process(delta):
if click == true:
crossair.global_position = touch_pos
if path.size() > 0:
move_to_target()
func move_to_target():
if global_position.distance_to(path[0]) < threshold:
path.remove(0)
else:
var direction = global_position.direction_to(path[0])
velocity = direction * SPEED
velocity = move_and_slide(velocity)