0 votes

Few things with Godot built in 2d navigation.

  1. 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.
  2. 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():
animation
player.play("walking")
Destination = WorldPOS.castleposition
Master.position = Vector2(1200, 300)
path = Nav
poly.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)
Godot version Godot v3.4.4
in Engine by (101 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.