im trying to click to move movement system with my new project. a little video.
[

character can leave a line behind it, but what i wanna achieve is, before the “click” to “move” when player click the move button and a half transparant version of the player sprite shows up,

between that sprite and orjinal player i wanna draw a line, like telling to player “you can move there”.

And i want to use the navigation agent to do so, because only paths can be walk will be in the navigation mesh. so only posibile patsh that player will see is in the navigation mesh. so i thong why not use navigation agent for this too, its a briliant idia !!! :frowning: .over 6 hours, i did try many things, can’t have the any result that solve this.

bdw i dont know if this is a bug, but im geting noting retrun from the navigation_agent.get_current_navigation_path()

i think, if i can get navigation_agent calculate the path that from player to current_mause_pos i can use that points to draw a line, but let alone doing that,

i cant even draw a line from player to current_mause_pos, godot do not let me draw outside of the _draw function,

i cant use the line.draw_line(vector2,vector2,color)

so yeah, my mind right now like a mushy mushroom, after hours of this problem, and i wanna ask here if there is a solution for this?

godot ver. 4.4

    newMorningKingdoM The draw functions are mostly used for debug information and you cannot draw outside of _draw(). So either do that or use a Line2D instead.

    i did kind of solve the click to move draw part after find out how to get return data from get_current_navigation_path()

    [

    func draw_to_target(line_2d : Line2D):
    	get_nav_agent.get_next_path_position()
    	path_array = get_nav_agent.get_current_navigation_path()
    
    	line_2d.width = 2.0
    	for x in range(0, path_array.size() -1):
    		var next_point = path_array[x + 1]
    		line_2d.add_point(next_point)

    i call this function in timer time_out signal and draw the line to the target point, but couldn't figure out how to adjust the fucntion so i can the draw a line from player to mause pos using the packedvector2array data that i get from get_current_navigation_path() ??

    after a lot of try and error, and a really helpfull tutorial finally i did it what i want, this is the tutorial if anyone interested;
    [

    and this is the result of the work

    after polish the few things im gonna share thi script here, thanks 🙂

    • Toxe replied to this.

      well yeah, its because of there im continuously drawing a line and remove it its flicker a little.

      if anyone interested this is the project.