[Behavior]PathFinder

Post your completed addons to share with the community

Post » Wed Sep 07, 2011 3:37 am




- THIS BEHAVIOR IS NOT SUPPORTED ANYMORE, PREFER USING THE OFFICIAL ONE -
The official pathfinding manual entry




The rest of this posts stays for legacy purpose, but if you are a beginner/newcomer/first time pathfinder user just go away now and stick with the official behavior/documentation. Pathfinding examples are provided with your Construct2 installation in the folder "examples".




-*-*-



A pathfinder allows you to find the shortest path between a source and a destination, while avoiding obstacles on a map.
Check this demonstration which also acts as the pathfinder's documentation.

You can download the example .capx (it is fully commented)
You first need to have a copy of the behavior in your C2 folder before being able to load the .capx

And for your pleasure the Pathfinder behavior itself.

Unzip the content of pathfinder.zip in:
[code]C2_base_folder\exporters\html5\behavior[/code](it should create a 'pathfinder' folder and the files should sit nicely in there)

You can also find a new example showing you how to move an object with the pathfinder behavior.
This example is available here
Here also come an example allowing you to display "in real time" the possible path the unit might take. Get it here now.

Have fun finding paths.

Important note about the usage of the PathFinder

Now the PF boards is accurate with the setting of the obstacles, no matter what their size is, as long as you respect the square grid aspect in your level design.



Quick image to show, the blue "mask" represents what the PF knows as "unwalkable" squares. The red sprite is the player.
You can see the first wall on the top left has a "double" mask compared to the other obstacles.
It's because of its position.
The CSS (Cell's Side Size) there is 32. And the wall's position happen also to be 32, meaning it sits on the edge of 2 squares.
And so it will appear as your sprite is avoiding the wall when it seems it should walk right next to it.

So if you respect the positioning of the obstacles in your level designs, it will work as intended (the rest of the blue masks).


Change/edits log:
[quote]
11-09-2011: Reuploaded PFDemo.capx and the C2runtime.js from the demo to fix a bug in the drag/drop method (When dragging Source on Destination, Destination also get picked as to be dragged/dropped. And vice versa.)
13-09-2011: Reuploaded PFDemo.capx and the C2runtime.js from the demo to fix a bug when clicking the GUI panel button, if the panel was showing/hiding and/or the commands fading in/out.
Update to the PathFinder behavior runtime itself (setCellSizeSide). It appeared that the PathFinder was looking for a path out of the layout boundaries.
09-01-2012: Update to the PathFinder Behavior: corrected bugs concerning the cleaning of the ObstList and the bounding boxes of obstacles. If you had prior troubles with having several obstacles, this should now be fixed, and you should be able to place/use obstacles far more easier.
Fixes thanks to @Yann.
Moving the object with pathfinder behavior thanks to @Yann & myself.
16-01-2012: Update to the PF behavior. Fixing of all previous bugs, fixing of the obstacle recognition (wasn't good enough yet). Fixing of the moving example and addition of the moving with preview example.
[/quote]Kyatric2013-07-06 00:40:41
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791

Post » Wed Sep 07, 2011 4:26 am

I think it could be very useful.
Thank you !
B
21
S
5
G
5
Posts: 163
Reputation: 5,028

Post » Wed Sep 07, 2011 4:28 am

i love you...in the manliest of ways...lol.
B
50
S
17
G
15
Posts: 1,029
Reputation: 26,289

Post » Wed Sep 07, 2011 4:30 am

Thanks!
B
31
S
6
G
7
Posts: 140
Reputation: 5,983

Post » Wed Sep 07, 2011 5:15 am

Always wished we had a behavior like this for CC.
Good job! Glad you got it working.
Image Image
B
161
S
48
G
89
Posts: 7,347
Reputation: 66,249

Post » Wed Sep 07, 2011 7:04 am

Thanks for the comments.
let me know if you find bugs or have a hard time using the behavior despite the example/documentation.

Kyatric2011-09-07 07:09:57
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791

Post » Wed Sep 07, 2011 8:04 am

Good job and very useful!
B
23
S
4
G
7
Posts: 98
Reputation: 5,220

Post » Wed Sep 07, 2011 8:14 am

That is is very, very good. I commend you, sir
If your vision so exceeds your ability, then look to something closer.
Moderator
B
120
S
28
G
68
Posts: 4,840
Reputation: 48,281

Post » Wed Sep 07, 2011 9:32 am

That's great, I've wanted to make it in CC, but never really finished, thank you.
ImageImage
B
25
S
6
G
8
Posts: 773
Reputation: 6,643

Post » Wed Sep 07, 2011 9:58 am

I got error while loading and just when I posted the problem I found out I put the behavior into the plugin's folder
ImageImage
B
25
S
6
G
8
Posts: 773
Reputation: 6,643

Next

Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 4 guests