get_simple_path returns empty array

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Zaorish
:warning: Old Version Published before Godot 3 was released.

Hi,
I’m trying to repeat godot-pathfinding2d-demo, but my

points = get_node("../Navigation2D").get_simple_path(get_global_pos(), get_global_mouse_pos(), false)

returns empty array all the time. Can someone help me to understand where is the problem?

Scenes:

tileset.tscn
tileset (Node)
->floar (Sprite)
→ ->NavigationPolygonInstance
->wall
→ ->StaticBody2D
→ -> ->CollisionShape2D

player.tscn
player (RigidBody2D)
->player (Sprite)
->CollisionShape2D

level.tscn
level (Node2D)
->Navigation2D
→ ->TileMap
->player

player.gd

extends RigidBody2D

export var speed = 200
const eps = 1.5
var points = []

func _ready():
    set_fixed_process(true)

func _fixed_process(delta):
    points = get_node("../Navigation2D").get_simple_path(get_global_pos(), get_global_mouse_pos(), false)
    print (points)

if points.size() > 1:
    var distance = points[1] - get_global_pos()
    var direction = distance.normalized()
    if distance.length() > eps or points.size() >2:
        set_linear_velocity(direction*speed)
    else:
        set_linear_velocity(Vector2(0,0))
    update()

func _draw():
    if points.size() > 1:
        for p in points:
            draw_circle(p - get_global_pos(), 8, Color(1,0,0))

I ran into this problem too, but not exactly sure what the problem with yours is. Try checking your tiles make sure the navigationpoly is exactly the size of the texture and make sure its enabled.

haz | 2017-07-27 20:30

:bust_in_silhouette: Reply From: Zaorish

Have found my mistake: it’s appears that I have added Navigation Polygon, but didn’t actually draw it… stupid me.

Now it’s seems to work, but sometimes player stuck on border of two tiles.