Easy Pathfinding with NavGO

Hey everyone,

I’ve been working on an easier method to do pathfinding with Defold. After some experimentation and successfully using it within several small projects, I feel that it is ready for public testing and utilization.

I am calling it NavGo (Navigation Game Objects). It works through having the user place down various nodes around the level/collection. During runtime, a map is created of the connections between all nodes, connections can include or ignore collision groups. The generated map can then be used to calculate paths throughout the game space.

Currently there are two ways to accessing the map data:

  1. By using a singleton named “NavGO_Global”.
  2. Through messaging the NavGo Handler Game Object.

I have attempted to document the system as best I can in the github repository ( https://github.com/DrCampbell2017/NavGO).

Screenshots:
Layout In Editor:

Includes a Debug Mode for seeing the paths created:
Note, you can set the max distance between nodes for a path to be created, hence why the bottom two do not connect.

During Runtime, all nodes are automatically hidden:

Example:
Here is an example project I made with the NavGo:


With the above example, there is currently an AI bug that causes the enemies to run from the player, this is not an issue with the NavGo

Links:
Defold Asset Page: https://defold.com/assets/navgo/
Git hub project page: https://github.com/DrCampbell2017/NavGO

The github repository also includes a small project where the NavGo can easily be demonstrated both by messaging the NavGo Handler and by using the singleton.

Side Note:
This is also my first time using the public repositories on github, I have no idea how to create the “archive/master.zip” I see on other projects. Help doing that would be amazing!

Feedback wanted:
I still have this project marked as an Alpha release. Please let me know if you discover any bugs, have any feature requests or other comments on what I can do to improve this project.

Thanks for the read and good luck on your projects!

21 Likes

This is available automatically: https://github.com/DrCampbell2017/NavGO/archive/master.zip
Clicking the link will download the master branch of your repository.

3 Likes

Perfect! Thank you!

1 Like

I saw this month back and could not remember the name. Went to assets and saw navo but it was missing all your images and animations so I figured it was a different library- today decided to just scroll thru projects till I found the images and behold its the library!

Im gonna check it out as Im porting a bloons td clone from godot and need easy node paths. Hopefully this will work like a charm.

3 Likes

Best of luck on your project, that sounds really cool! If you need me to me add anything specific to the NavGO or if you have questions concerning my documentation/sample implementation, don’t hesitate to ask!

Today I will be downloading and implementing it on map1. Ill post an update and screenshot if I get it working.

1 Like

Hey could you give me walk thru on installing this.

I cut and pasted to the dependencies on project settings clicked fetch libraries, then ran build to test and it gave me java websocket error could not connect. So I removed it.

My first time trying to use a library with defold. Thanks for your patience.

1 Like

Sure!

So, when you have you project open, click on the game.project file.


From there, go down to dependencies. Click the “+” Icon

Copy and paste in the link you need for the desired dependency, in this case, NavGo with the URl of “https://github.com/DrCampbell2017/NavGO/archive/master.zip” . Sometimes it is better to point to a specific release so a major update doesn’t change your code, this can also leave in existing bugs in the library. There’s no easy solution, if you want the latest version instead of master, here’s the URL: “https://github.com/DrCampbell2017/NavGO/archive/Alpha.10.zip

Next, use the fetch dependencies button located under the project tab. It may take a moment to be included into the project depending upon the size. You will see a loading bar in the bottom right hand corner as it fetches the library.

If everything completes successfully, the library will be included in your assets window with a puzzle-piece icon next to it.

There’s also a Defold made tutorial here you can refer to: https://defold.com/manuals/libraries/

You mentioned having a java web-socket build error with it. That could be a number of things, to troubleshoot, I recommend checking:

  • If your project still builds if you remove the dependency
  • If the dependency is in your assets window (if not, check the URL in the game.project file, you may have a spelling error)
  • Try with the latest release instead of the master.zip
  • You may just need to restart Defold and/or your computer. I get that specific error when my speakers refuse to play audio (something’s wrong with my driver, I’ve had this issue long before I started using Defold).

Best of luck!

7 Likes

Got the libraries installed! Now to test them… :):nerd_face:

2 Likes

Could you send me a little example of this implemented in a collection? I got as far as getting library installed, adding the handler go to the collection and the nodes to the collection and adding the init code to my script for the collection. But Im not really sure what to do next.

Im having chemo brain fog sorry :slight_smile: and thanks

Nevermind I just realized the readme was in a game example on github.

sigh

OK Ive explored the example.

I am not understanding the order the path takes on the nodes.

Could you tell me how to make the character follow the nodes in order node1,node2,node3,etc Im using this to follow a drawn path not to navigate around things.

Just saw your message, I’m making a slight modification to the NavGo to make it easier for what you are looking to do.

1 Like

Thanks!

I am building this game in Godot and Defold. The chemo is really slowing my porting progress to Defold. Plus Im old!. So appreciate the help :slight_smile:

Some things about Defold are much easier for me than Godot and also vice versa. Object following paths is one of those things.

Thanks TTYL

I added in a new type of node called the ‘directional node’, referred to in the library as “/NavGO_directionalNodeGO”.

Using this node can create one way paths (as seen in blue) and also be optionally connected with the standard NavGo node (connections seen in red)

To use this new type of node, add it to the level, it will have three additional values within the script, “Node ID”, “Node Next” and “Independent Path”.

  • “Node ID” is a number value to hold the ID of the node.
  • “Node Next” is a number value that holds the ID of the next node to traverse to.
  • “Independent Path” is a bool variable. True will exclude it from general pathfinding while false will include it in. For example, if this value is false, the function NAVGO.GENERATE_PATH_TO_RANDOM_NODE() could select the node to generate a path to.

Currently, the ID value has to be manually put in every time. I am unaware of any way to auto increment the value when adding a game object to the collection. If anyone could let me know how to do that, I would be extremely thankful.

To use this new directional node, I’ve added in two new functions:

  • NAVGO.IS_DIRECTIONS_READY() will check if the directional nodes are ready to be used.
  • NAVGO.GET_PATH_FROM_DIRECTIONAL_ID(start_node_id, end_node_id) will calculate the path from one ID number to another along the defined path.

Currently this directional path can only be accessed by the singleton, if anyone needs me to add it to the NavGo_Handler as a message, let me know and I can do that for you.

I have created another sample level to demonstrate how this new type of node works. This example has two separate paths being followed by two separate characters as well as third character that will randomly traverse to different nodes.
I have also updated the ReadMe.md with instructions on how to use it.
Here’s a link to the latest release: https://github.com/DrCampbell2017/NavGO/releases/tag/Alpha.11

5 Likes

If you need anything else added, or need clarification on anything, feel free to reach out!

It’s cool that you’re porting your game from one engine to another. I’ve used Defold for about three years now. I learned it during college for fun and have just used it since. I don’t really have the time to learn another engine as I work full time now.

I’ll be praying for you, hope you get better soon!

5 Likes

Thank you I will try it out soon. :slight_smile:

IN response to your question about auto numbering- when you place a node could it not be stored in an array of follow path nodes and use the array to do an array length+1 to get next node number and that serve both as id in array as well as node id?

I am using your example as base:

I delete the nodes then I add new nodes, set id and goto next on each and it throws an error:

Here are the errors I get: ERROR:SCRIPT: /navGo_pathfinding/NavGO_Global.lua:135: attempt to index a nil value

stack traceback:

If instead I leave some of your nodes on and try to add another node then it just ignores the new new node even after updating the id and goto next on the relative nodes, and bounces back and forth between the first and next to last node.

I am sure I am skipping step. Remember I am doing this on the game example. Which runs fine, I remove unwanted nodes and it runs fine. I add new nodes and it fails.

here is what I did exactly:

To add I goto the collection add game object file, then go to to direction node and add sprite component and node directional script script then update the id and next and independent path. I make sure the previous node points to this node.

BTW I am cancer free as of today! Doing my last chemo this week.:slight_smile: Soon Ill be a coding demon ! LOLZ

2 Likes

Congrats on being cancer free! That’s amazing!

As for your question, the path you created so far is perfectly fine, the problem is coming from the “directional character GO”. Within the game object script, I have defined a “Start Path ID”, an “End Path ID”, and “Speed”.

The “Start Path ID” is the directional node ID where the character will start and the “End Path ID” is the node which it will end at. Giving either of these values an ID that does not exist will thrown the “attempt to index a nil value” error you are encountering. For your example, I suggest changing the “Start Path ID” to 1 and “End Path ID” to 2, as seen bellow in the screenshot. That fixed it when I tried it.

My apologizes for not explaining that the first time, I entirely skipped over that part in my documentation.

In regards to your auto numbering solution, I may play around with that some and see if it works. Thanks for the suggestion!

Best of luck! Let me know if you need anything else!