![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Matt’sGames |
I
On Godot3.1
Keeps changing its mind about which path to take
not sure if this is a bug.
doesn’t happen if the simple path has optimize=true
but I don’t like the look of that path as much
func _ready():
get_parent().get_parent().connect("placetile", self, "updatepath")
self.position = get_parent().get_node("spawn").global_position
goal = get_parent().get_node("end").global_position
nav = get_parent().get_node("Navigation2D")
path = nav.get_simple_path(self.global_position, goal, false)
get_parent().get_node("Line2D").points = PoolVector2Array(path)
get_parent().get_node("Line2D").show()
func _process(delta: float) -> void:
if !path:
return
if path.size() > 0:
var d: float = self.global_position.distance_to(path[0])
print(path)
if d > 10:
self.position = self.global_position.linear_interpolate(path[0], (speed * delta)/d)
else:
path.remove(0)