Pathfinding
-
Anyone know of an efficient way to integrate pathfinding in a top-down game? It’s been my biggest roadblock in a couple of projects I’ve tried to create lol. Thanks!
-
@bosswave I've been searching for that too, couldn't find something simple enough. I saw a project of RobinsonX with a path finder systems, but I don't know if it would fit in all games ^^"
-
I recently created a project that involves pathfinding and it works PERFECTLY! (Not the hyperPad one)
Unfortunately, it has been written in another language though. BUT, I can explain it.
-
Here is the URL for a simulation of it. (Yes, it involves real-world code.)
https://py3.codeskulptor.org/#user305_LsWXuY7iAj_7.py
You can observe what is happening. (Works best on Computers)
-
If I can find any time, I can update my path-finding project in hyperPad. (it's outdated)
-
Alright, I'll try to explain it. (Sorry if this is too much.)
(Okay, it is too much...)
Here's a "simple" tutorial.
- Have a
gridof solid blocks and non-solid blocks. - Let
Point Abe the starting point andPoint Bbe the destination. - When you want to find a path, perform these execution in order:
- We will have blocks spreading from
Point B. LetGrowth Blockbe a function.Growth Blockchecks all of its side (up, right, bottom, left) and places aGrowth Blockfor each adjacent non-solid block IF it has not been occupied previously with aGrowth Block. After that, it sets a value, let's call itD, in it's place and whateverGrowth Blocksit had just summon will set a value ofD + 1instead ofDalone. So theDvalue from the destination should be smaller than the values further from it and vice versa. - Starting from
Point B, have blocks spread from it.Point Bexecutes aGrowth Blockin it's place.Dshould be initially set to 0, but any number would theoretically work. Notice thatGrowth Blockstarts a chain reaction where a single block clones into more blocks and covers the whole grid. - After the
Growth Blockhas stopped executing, or when the spreading stops, and the starting point has not come in contact with anygrowth block, then there is no possible path. - Otherwise, if the starting point has come contact with
Growth Block, then there is at least one possible path.
— We are only just NOW finding a path —
- From the starting point, trace a path from the adjacent
Dvalues given. Let's have an object, calling itBob. You can do this by checking the currentDvalue whereBobis. Bobwill check the surrounding blocks and will move in the direction whereDis less than theDvalue atBob. In other words,Bobis moving towards blocks with smallerDvalues.Bobwill repeat this process of looking and moving until the destination has been met.
- After a path has been found, you can make whatever character or object follow that path. The path that
Bobtook can be recorded in an array, a list of directions telling how to get to the destination. - If for some reason, the
environment changes, like having a block added or removed, the process shall be repeated. (Or not, it depends on the situation.)
- Have a
-

This is what you should see. (It won't let me place blocks on Mobile.)
https://py3.codeskulptor.org/#user305_LsWXuY7iAj_7.py -
@RobinsonX that... actually helps a lot. Thanks!
Now let’s just see if I can replicate this lol.
Edit: sorry, I keep forgetting to change the account on my phone.
-
Hyperpad writes to cocos2d which actually has a bunch of tutorials on pathfinding. Im pretty sure it can be possible with hyperpad if new behaviors are introduced to support it.
-
We actually have a tutorial on a basic path finding system
https://hyperpad.zendesk.com/hc/en-us/articles/360031030412-Grid-based-Path-Finding -
@Murtaza thanks, I’ll definitely take a look at it!