My path-finding keeps breaking!

Get help using Construct 2

Post » Sun Feb 03, 2013 7:42 pm



Not sure what the problem is. I have a system where each unit (arrow) has a dictionary file that stores the information of where the item will be going next. I probably should use an array for this kind of information, but arrays still confuse me slightly.

In any case, the dictionary is in a container with the unit, and when the unit reaches its destination, the dictionary will find a new location. The unit will then turn and find its way to the new location. I also have an event that states that if there is no path to be found, the dictionary will pick a different location. The logic seemed to work, and so I made many more objects to see how many it could cope.

I noticed now, though that some of the units just decide to stop. I added a sprite to appear at their destination to see if they got stuck in the obstacle, but that doesn't look like that's that problem.

Click here to see what I mean

The path finder is so simple to use, it's brilliant... but I just want to make sure it can handle what I plan on throwing at it. I find I'm a little concerned over its potential. So far, the only uses I can imagine it for is a top-down game.

Can it:

Control isometric units?
I imagine it can, but I have tried it with my 4 directional sprite man, and he looks a little silly walking diagonally. Can I restrict the path finder so that it will only locate paths using 4 directions, 8 directions, etc?

Control platform NPCs
I saw a pathfinder once that could allow a character to navigate the faster route to a point by using ladders and even transporters.

Again, is this only really practical for top down movement? I don't mean to put it down in any way. It's brilliant and simple to use. I just want to know if I can use it for my game.AnD4D2013-02-03 19:44:38
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
68
S
8
G
6
Posts: 930
Reputation: 9,358

Post » Mon Feb 04, 2013 9:36 am

Anybody else having trouble with failed paths not switching to a new one? I'd like to know if this is a glitch, or something wrong with my events.
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
68
S
8
G
6
Posts: 930
Reputation: 9,358

Post » Mon Feb 04, 2013 3:28 pm

In Event 6 you need to find path to (Dictionary.Get("X-Position"), Dictionary.Get("Y-Position")) at the bottom of the event.
When one failed to find a path all you were doing was changing the dictionaries x,y and not actually finding a new path.
B
40
S
12
G
7
Posts: 603
Reputation: 7,656

Post » Mon Feb 04, 2013 3:56 pm

Ahh, brilliant! Thanks @EncryptedCow! Any idea on the potential of this plugin? Can it be used for platformers? Isometric games?
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
68
S
8
G
6
Posts: 930
Reputation: 9,358

Post » Tue Feb 05, 2013 3:55 am

Yeah I think this is one of the best behaviors yet. It can be used for TDs,RTSs, Player Movement, could also be used for sleek menus I guess.
B
40
S
12
G
7
Posts: 603
Reputation: 7,656

Post » Tue Feb 05, 2013 1:10 pm

@EncryptedCow

But not isometric games...

Not easily at least.

Alright, not a problem, I'll come back to this game in the future.
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
68
S
8
G
6
Posts: 930
Reputation: 9,358

Post » Tue Feb 05, 2013 7:51 pm

I don't see why you can't use it for isometric games - you just need to manually set the collision map, as isometric graphics collision != object collision
B
8
S
2
G
3
Posts: 83
Reputation: 2,668

Post » Tue Feb 05, 2013 10:04 pm

@tanoshimi

As long as I don't intend on my character ever changing direction animation, it's fine. Otherwise, it'll take a lot of events. Also, I'd prefer to limit the movement so that the path finding only works in either 4 or 8 directions. You know, the ability to disable diagonals if I want. Imagine Pokemon games, but suddenly being able to walk at a 32 degree angle. The animation would just look odd.
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
68
S
8
G
6
Posts: 930
Reputation: 9,358

Post » Wed Feb 06, 2013 9:43 am

I'd agree that *animation* is isometric games certainly involves more work, because you'll have to render frames for each facing direction, but that's nothing to do with pathfinding!

If you want to disallow diagonal paths in the route returned by the pathfinding plugin then you need to delete/comment out the diagonal cells added to the openlist in lls 380 and 402 of pathfind.js, so that you only have the following:

if (!obsLeft)
this.addCellToOpenList(x - 1, y, 10);

if (!obsTop)
this.addCellToOpenList(x, y - 1, 10);

if (!obsRight)
this.addCellToOpenList(x + 1, y, 10);

if (!obsBottom)
this.addCellToOpenList(x, y + 1, 10);

// Diagonal cells commented out as follows
//if (!obsLeft && !obsTop)
// this.addCellToOpenList(x - 1, y - 1, 14);
//if (!obsTop && !obsRight)
// this.addCellToOpenList(x + 1, y - 1, 14);
//if (!obsRight && !obsBottom)
// this.addCellToOpenList(x + 1, y + 1, 14);
//if (!obsBottom && !obsLeft)
// this.addCellToOpenList(x - 1, y + 1, 14);

Don't know how that fits with the general policy of "not editing the core plugins" though...!
B
8
S
2
G
3
Posts: 83
Reputation: 2,668

Post » Wed Feb 06, 2013 4:43 pm

@tanoshimi

My point was effectively saying that it turned into work overload. Sure it's possible to use it with the path finding behaviour, but take the following for example.

I have one character that has an idle animation, a walking animation, a running animation, a sword fighting animation, a bow shooting animation, a sitting animation, a feeding animation, a sleeping animation, and a dying animation. So that's 9 different animations, with the possibility of adding more in the future. Now, this character has this same animation rendered out in 3D and then had a sprite generated for 32 different angles. This means that I will need to have a grand total of 288 separate animation files within that character, with each one requiring an event to deal with each action on each degree of rotation.

Again, while this is all possible, it is very impractical, and means that it's unlikely that people will use the path finder for these kinds of games just yet.

It's a great behaviour, and I'm sure some people will be able to do great things with it, but for the time being I feel that sadly at this moment in time it's limited in what can be achieved. Not putting the path finder itself down at all, I honestly think it's great. I could make my game top down and only have to work with 9 animation files, and have the system automatically rotate using this tool, but I feel it would look pretty awful compared to isometric.

@Ashley - Sorry to pull you into this. Do you know whether we can edit the core plugins to allow or disallow directions as and when we choose? 4 directions, 8 directions, etc, as suggested by tanoshimi's above post?
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
68
S
8
G
6
Posts: 930
Reputation: 9,358

Next

Return to How do I....?

Who is online

Users browsing this forum: mercuryus, Naightwolf, Skebab, Swivels and 22 guests