Hey, I am looking to create something similar to the resource system in creeper world, ultimately I want little resource packets (sprites) to travel along pathways between nodes to their destination as required - See example https://youtu.be/XtHgFz-d4TY?t=1215 or even something like this old flash game (The Space Game) https://youtu.be/VI6smKzHuHQ?t=778
I've had a little look around the forums & haven't found anything similar. If someone can direct me to an example or give me some tips as to where to start on the research for this I'd greatly appreciate it.
Thanks!
Develop games in your browser. Powerful, performant & highly capable.
The pathfinder behavior works by dividing the level up into squares and uses the a star algorithm to find the closest path. You can implement a star with events to use a node mesh. This site is a great reference:
redblobgames.com/pathfinding/a-star/introduction.html
Looking through my files I found two examples of that. The first is newer, but I included the older one in case that gives ideas.
uc19541885dca4590897d4d9e64e.dl.dropboxusercontent.com/cd/0/get/Ch5yyT0nnUjM2BaqWblThXB0oz2iTJnABqaGj30_OGx17QL29LU8COOfKiprYc5_OGQYG3VxVw7Lcp5FfZBrDV4cW1tZXbZdJsefTXTp6VScVTBPq6sPBglMB4quzS-tRWg/file
uc7121f19f6cad88394e8629d5b5.dl.dropboxusercontent.com/cd/0/get/Ch7SpUEmpVdgxOmZa1ZUkJ99cD1Pbrz6g-3WILKk9UwBxyxVlsjpT-MTRMmIq5Hzymjq060g-A1hp-V_L_rLJSn_sBJUaZ75sX859t_jGvjYjK_UFKKyDt19HxA8n5jKleo/file
So basically if you used the first one, just place nodes and lines between them to make connections. Then calling the "astar" function with the uid of the start and end nodes will give you a comma separated list of the nodes that would make up the quickest path.
The latter part of the example gives a possible way to move the object through that list of nodes. There are other ways.
Ah yes this is the good stuff!
Thanks R0J0hound!