Attention | Topic was automatically imported from the old Question2Answer platform. | |
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.
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:
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
hi, do you get solution? i have same problem.
potatobanana | 2020-03-13 16:00