Simplest pathfinding around a tilemap track

Just started using Construct 2? Post your questions here

Post » Wed Jan 06, 2016 1:32 pm

Here's a capx of a tilemap track with a sprite wants to find it's way from Start to Finish: https://www.dropbox.com/s/wg69djmnroga9 ... .capx?dl=0

I saw this great example by @rexrainbow : request-car-pathfinding_t125153
And another pathfinding method: behavior-easystar-js-pathfinding-for-tilemap_t129056

But they seem quite tricky to set up, and I haven't got the greatest understanding of angles and loops, so I was wondering if the sprite could "drive" or crawl it's way around the track using the simple tools provided in c2? I tried it with solids, 8-dir and pathfinding, but the sprite just hit the wall and refused to go around the maze, and I'm concerned the built-in pathfinder might get stuck and I really need the sprite to always be moving, trying to find it's way around the track. Any suggestions as to how I could get started with the simplest method possible would be great!
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,248

Post » Wed Jan 06, 2016 2:14 pm

The origins on your Start/Finish blocks were bad, so that caused some confusion at first. When corrected, simple pathfinding works fine.
www.blackhornettechnologies.com/Constru ... r_BHT.capx
ImageImageImage
B
71
S
21
G
203
Posts: 3,582
Reputation: 115,008

Post » Wed Jan 06, 2016 2:29 pm

@Zebbi : You should really have a look at your origin-points, this is not the first time they are in the wrong place in the projects you shared..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Jan 06, 2016 10:21 pm

LittleStain wrote:@Zebbi : You should really have a look at your origin-points, this is not the first time they are in the wrong place in the projects you shared..

Sorry, I wasn't aware the origin points were important in pathfinding, I've found that cloning items causes some strange origin point offsets, and alot of the time I haven't noticed any particular issues.

blackhornet wrote:The origins on your Start/Finish blocks were bad, so that caused some confusion at first. When corrected, simple pathfinding works fine.
http://www.blackhornettechnologies.com/ ... r_BHT.capx

Wow, thanks for that, really helpful! I wasn't totally sure if it was possible or effective with pathfinding, but you've proved very well how effective it can be! :D
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,248

Post » Wed Jan 06, 2016 10:44 pm

Zebbi wrote:
LittleStain wrote:@Zebbi : You should really have a look at your origin-points, this is not the first time they are in the wrong place in the projects you shared..

Sorry, I wasn't aware the origin points were important in pathfinding, I've found that cloning items causes some strange origin point offsets, and alot of the time I haven't noticed any particular issues.

blackhornet wrote:The origins on your Start/Finish blocks were bad, so that caused some confusion at first. When corrected, simple pathfinding works fine.
http://www.blackhornettechnologies.com/ ... r_BHT.capx

Wow, thanks for that, really helpful! I wasn't totally sure if it was possible or effective with pathfinding, but you've proved very well how effective it can be! :D


Origin points determine the x and y position of the object, regardless of the image part of the object, so yeah, kinda important..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Jan 06, 2016 10:49 pm

Good point, im working on a game that requires pathfinding, and had a couple of issues, but this fixes it. Now I'm aware of it too ☺
B
32
S
14
G
4
Posts: 172
Reputation: 4,008

Post » Wed Jan 06, 2016 11:26 pm

blackhornet wrote:The origins on your Start/Finish blocks were bad, so that caused some confusion at first. When corrected, simple pathfinding works fine.
http://www.blackhornettechnologies.com/ ... r_BHT.capx

@blackhornet Quick beginner's question, how can I do "laps" in this way? I want to have the sprite cross the finish line an go around again, I've tried it with variables and also with offset overlaps, but due to the object either not quite reaching the destination marker properly, or trying to turn around at the end, I'm not sure how to go about this? Basically, once it hits the finish, it needs to go around again, preferably with as few markers around the track as possible (we are pathfinding after all!) and with no risk of the sprite turning around and going backwards.
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,248

Post » Wed Jan 06, 2016 11:41 pm

What I would do in this case is use the patfinding behaviour to find the path and the bullet behaviour to move along the path, that way the path only has to be found once and when the last node is reached you could set the direction for the first node again..

Something like I did in this example:
https://dl.dropboxusercontent.com/u/485 ... erlap.capx
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu Jan 07, 2016 10:47 am

LittleStain wrote:What I would do in this case is use the patfinding behaviour to find the path and the bullet behaviour to move along the path, that way the path only has to be found once and when the last node is reached you could set the direction for the first node again..

Something like I did in this example:
https://dl.dropboxusercontent.com/u/485 ... erlap.capx

This looks great, but it looks like a lot of maths. Is this way vastly superior to the method of pathfinding and moving? I appreciate that to do multiple passes of the same path might be more tricky, but is there no easy way of having the sprite loop around the path without using too many extra movements and expressions?
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,248

Post » Thu Jan 07, 2016 11:06 am

Most of the math in that example is to prevent the overlapping..
All you'd need is the part that does the bullet instead of the follow path..

Like this:
https://dl.dropboxusercontent.com/u/485 ... rcles.capx
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Next

Return to Beginner's Questions

Who is online

Users browsing this forum: chrisinfinger and 1 guest