The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

I'm creating top down game with tile based movement, and I want to add the possibility to move to a position by clicking the mouse button. To do so, I created a function which take an array of directions and follow the path.

I'm using the Navigation2D node to make the pathfinding (I added the tilemap as a child of the Navigation2D) and get the position array, but the points doesn't seems to be correct.

Here is an example:
enter image description here

I'm using this simple function:
var points = navigation.get_simple_path(position, destination, false)

If I click on the marked tile, here is what points contains :enter image description here

With a tile size of 32px, I don't understand why each position is incremented by 16px.

Also if I click on the tile just to the right of this one, here is what I get :enter image description here

It seems to make a diagonal movement, but it's probably intented ?

Finally, here is how I created the NavigationPolygonInstance in the Tileset, because it may be related to this :
enter image description here

I think I don't understand how the Navigation2D works, what am I doing wrong ?

in Engine by (17 points)
edited by

Only need change false to true:

var points = navigation.get_simple_path(position, destination, true)

1 Answer

+1 vote
by (42 points)
edited by

In this video you can see demonstration of above mentioned approach:

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 Frequently asked questions and 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 [email protected] with your username.