0 votes

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)

    #Enemy.set_path(path);
    $Line2D.points = path;

Any suggestion? It's my first game btw :D

in Engine by (16 points)

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

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 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 webmaster@godotengine.org with your username.