[Behavior]PathFinder

Post your completed addons to share with the community

Post » Wed Jan 11, 2012 8:17 pm

Today I also noticed that moving the pointer outside the canvas is a sure way to crash it. Increasing the path generation frequency from every tick to a second allows it to survive longer but it eventually fails.

Also edited the capx a bit more.
B
47
S
3
G
5
Posts: 56
Reputation: 4,630

Post » Wed Jan 11, 2012 10:12 pm

This plugin isn't really designed to allow for such a usage.
Calculating paths each tick out of a target that may be indeed out of layout will cause it to freeze/crash.
And I'm really not sure how to prevent it atm.

If you want to preview a path for your unit though, it's another logic to be used.
I'll include another example with the release.

It might take more time than just a couple of days as this is not the only matter on my hands.Kyatric2012-01-11 22:12:25
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,999
Reputation: 57,793

Post » Wed Jan 11, 2012 10:23 pm

In other words, I'm doing it wrong. :) It's always better not to rush it, take your time. ;)
B
47
S
3
G
5
Posts: 56
Reputation: 4,630

Post » Sun Jan 15, 2012 10:03 pm

I played with this a bit more and I'm sorry to say that either construct or the pathfinder behavior is looking for an excuse to crash. I found acceptable workarounds for most issues but here is the one bugging me at the moment:

I used the information on this thread for for previewing my path target by picking instances. Used @Yann's and @Kyatric's methods there and am having issues. I also had to lay invisible sprites around like a noob because that's all I could think of.

v1.capx
Yann's version. Instances aren't deselected properly and they often remain picked over the mouse's trail. Probably c2 issue. Workaround is to reduce the hotspot by at least 3 pixels on all sides. Quite unacceptable. Why can't there be "on mouse enter" "on mouse leave" conditions?

v2.capx
Kyatric's method. Reason why I'm using this thread right now. Successfully picks only one instance at any given moment but line 6 is problematic. Moving the mouse pointer outside the canvas or switching tabs around by mouse shortcuts locks the application up. Can't know if it's a c2 or pathfinder issue. Maybe this is simply the result of an overall unstable "on every tick" condition or maybe it only manifests itself when the pathfinder behavior is around. Either way, this is burning me out. :/

Additional request:
Pathfinder wants to register tiles with their middle pixel thus doesn't play well with the built in pixel grid. :/
B
47
S
3
G
5
Posts: 56
Reputation: 4,630

Post » Sun Jan 15, 2012 10:10 pm

Just a quick word, yes the PF is buggy at the moment, I still need time to fix it.

I haven't lookes at your capx, but it is likely, atm, that anything you'll do will end up crashing/failing because of the inner bugs of the PF.
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,999
Reputation: 57,793

Post » Sun Jan 15, 2012 10:27 pm

I'm hope you're not thinking I'm ungrateful. Quite the opposite, I'm posting this stuff for documenting what might be ironed out. :)

Meant to add this as an edit actually but it's also a seperate question. Can cells with other than square aspect be possible? Like 84x48? Until now I thought we could specify cell width and height seperately but it appears that's not the case.
B
47
S
3
G
5
Posts: 56
Reputation: 4,630

Post » Mon Jan 16, 2012 12:23 am

First, the PF maps a grid of square cells on the whole layout. You can only set CSS (Cell's Side Size) which is applied to both width and height.
This is by "design" and I'm not sure how providing the ability to set different sizes might affect the PF in the end.
It might end up in doing another PF behavior and I'm not ready/willing to dig into that atm (I'm sorry, I don't need a PF behavior with those features). Still I'm trying to provide this "simple" (but not much flexible) behavior for now.

So with this out of the way, I've resolved the obstacle recognition in the PF. 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 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).

The "big thing" that left for now is that to make the recognition work, I had to use a little trick. The square, for the PF is actually 1 pixel smaller than CSS value (31X31).
And so when you put your mouse on the position 32,32 for example, for the PF, it sets the destination point as nowhere. The destination square doesn't actualy exist.
So the algorithm freezes the whole thing.

The algorithm part of the behavior isn't code I written, so I'm uneasy going into it and hacking a solution.

SoI have already my hands full atm, and it is likely that the "new version" you report should be resolved once I'm done with the current issue.

So I'll check them as documentation and even as base to provide more examples of use of the behavior once it is done, and for that I warmly thank you, but for now please don't keep them coming ^^

Yeah to conclude another walltext, pathfinding is tricky, and this behavior won't be that flexible and constrain you in your design.
Still it will allow to cover some ground and should definetely be useful/usable up to a certain level.
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,999
Reputation: 57,793

Post » Mon Jan 16, 2012 2:10 am

Finaly it sounds as all I needed was to put things down "on paper".

Update, compatible with r75
You can download the pathfinder behavior and new (normaly fixed) examples from the first post of the topic.

@wronghands: I've just launched your two latest versions, they appeared to execute without freezing (which I was looking for).
Check the "moving with preview" example from the first post.Kyatric2012-01-16 02:11:52
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,999
Reputation: 57,793

Post » Wed Jan 18, 2012 11:11 pm

@Kyatric

I hate to distract you but I have to tell this: I don't think the pathlist generated by the latest version is 0-based.

When you set one neighboring cell as the source and the other as target, pathlistlength returns 2 instead of 1. This makes calculating movement costs impractical if not impossible.

Sorry for the interruption.

ExampleWronghands2012-01-18 23:12:30
B
47
S
3
G
5
Posts: 56
Reputation: 4,630

Post » Wed Jan 18, 2012 11:51 pm

The pathlist is an array.

The length returns the number of elements (cells) in the pathlist.
Pathlist[0] is the Source, Pathlist[pathlist.length-1] is the destination.
In the case of neighbouring cells, you have 1 the start, 2 the destination. Pathlist's length = 2

Works like the array plugin.
The trickyness comes from the fact that the very first cell (pathlist[0]) is always the source coordinates.
I might indicate/make this clearer in the documentation I guess.

Also atm I'm not working on the behavior. Bug reported have been fixed, it sounds like everything should work as intended.
So if you find bugs or have troubleshooting questions, I'm here to answer, no problem.
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,999
Reputation: 57,793

PreviousNext

Return to Completed Addons

Who is online

Users browsing this forum: DragoMej and 0 guests