Nav2D/TileMap path

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Crazy

Hey, I’m working on enemies for a tower defense game. I did a TileMap node (cell size of 32x32) as a child of Navigation2D and added a rectangle nav inside the tile. I also added a Line2d node to draw the path.

how it is

As in you can see in the image, it’s working, but regardless of the enemy’s position, the path is always the same. I want to do something like this instead:

how I wanna

And my code:

extends Node

onready var Enemy := $Enemy;
onready var Nav := $Navigation2D;
onready var Map := $Navigation2D/TileMap;

func _ready() -> void:
	var start: Vector2 = Enemy.global_position;
	var end: Vector2 = Map.map_to_world(Vector2(7, 4));
	var path: PoolVector2Array = Nav.get_simple_path(start, end, false)
	$Line2D.points = path;

Any suggestion? It’s my first game btw :smiley:

hi, do you get solution? i have same problem.

potatobanana | 2020-03-13 16:00