Navigation 2D and Get Simple Path
Hello and thanks for looking into my problem! Very new to Godot, coming from Unity, and I'm trying to work out how to do some simple pathfinding. I followed these two tutorials mostly while trying to figure this out: and https://www.davidepesce.com/2019/11/19/godot-tutorial-how-to-use-navigation2d-for-pathfinding/
My problem is that after putting together a scene with two tilemaps (one containing only textures and no nav/collision info), and the other built with navmeshes in the tileset (built from a scene).
This is the script managing input and attempting to draw the pathfinding line that is found with get simple path. It's attached to the root Node2D in the scene:
class_name NavigationInputManager extends Node2D onready var nav_2D : Navigation2D = $"Player Ship/Navigation2D" onready var line_2D : Line2D = $Line2D onready var player : Sprite = $"Player/Player Sprite" func _unhandled_input(event): if (event is InputEventMouseButton and event.button_index == BUTTON_LEFT and event.is_pressed()): print ($Player.position) print (event.position) var path = nav_2D.get_simple_path(player.position, event.position) line_2D.points = path $Player/PlayerController.path = path print(path)
For now, the playercontroller class does nothing, it's just a variable assignment.
Attached are three screenshots, the tileset to show how I have it set up, some output from the console that shows the character's position, the clicked position, and then prints the path; and a screen from the game that shows how the pathfinding line shows up. Any help would be greatly appreciated!