[Suggestion] Grid-based pathfinding behaviour

Discussion and feedback on Construct 2

Post » Fri Jan 24, 2014 1:04 pm

Hey hey,

I'd love to see a pathfinding behaviour that moves on a set 4-directional tiled grid. The current pathfinding behaviour doesn't work too well for that: even when turning off diagonal movement, rotate object and setting the cell side to the grid size etc, the sprite still 'drifts' around a few pixels as it moves. It also doesn't always end up on the exact tiled space it's going to - it'll often stop on the edge of a tile or a couple of tiles before it.

In other words, a system like the pathfinding behaviour we have now, where it'll find the shortest path from point to point avoiding obstacles, but the sprite only ever moves on either the X or Y axis as it travels, never both at once. The movement nodes should all be set at evenly-spaced points on a grid defined by the user (eg, a 100x100 grid of 16x16-pixel tiles, etc) and the sprite travels precisely between each point.

Hope I've explained well enough Is something like that possible? This would be a great feature to have for tile-based games like turn-based strategy, roguelikes and other RPGs, as it'd take a lot of the headaches out of moving sprites around automatically.lolpaca2014-01-24 13:42:23
B
15
S
4
G
1
Posts: 286
Reputation: 1,988

Post » Fri Jan 24, 2014 1:27 pm

In case that wasn't too clear, here's an example of how that movement would go:



If I'm being stupid and there's already a simple way to do this, please let me know because I'd love to know!
B
15
S
4
G
1
Posts: 286
Reputation: 1,988

Post » Fri Jan 24, 2014 2:48 pm

Definitely +1 for this!!

Even the 4-direction option doest really work well.
It seems to swim a little which looks absolutely stupid on walking enemys!
Image
Check out our start-up and configure your own helmet in true 3D.
B
44
S
11
G
11
Posts: 1,154
Reputation: 9,978

Post » Fri Jan 24, 2014 6:36 pm

I had a go at writing my own pathfinding in Construct, it worked but it was too slow. R0J0hound made a fast tile based one which you could modify to suit your needs.

Have a look at the thread http://www.scirra.com/forum/topic74810.html


Also forgot, i modified it to include movement costs over terrain types, and cancels if no path found.

https://dl.dropboxusercontent.com/u/159885981/AstarMAX.capxEthan2014-01-24 18:48:07
B
43
S
23
G
20
Posts: 735
Reputation: 12,027

Post » Fri Jan 24, 2014 8:51 pm

+1
B
50
S
11
G
7
Posts: 274
Reputation: 8,146

Post » Sat Jan 25, 2014 3:40 am

Thanks everyone - after a bit of looking around I found an Astar plugin which appears to be what I'm looking for. I'll have a play around with it and see how it goes. You can find it here:

http://www.scirra.com/forum/plugins-behaviors-rez-repo_topic51087.html
B
15
S
4
G
1
Posts: 286
Reputation: 1,988

Post » Sat Jan 25, 2014 8:50 am

This is what i was originally using for a game i was making a while ago but i found a bug in the way it finds paths, you can check my thread here http://www.scirra.com/forum/turn-based-strategy-like-advance-wars-devlog_topic74453_page1.html

I PM'd the author but didn't get a response.

I think rexrainbox does another pathfinding object though.Ethan2014-01-25 08:51:51
B
43
S
23
G
20
Posts: 735
Reputation: 12,027

Post » Sat Jan 25, 2014 10:21 am

It would be nice when new beta comes with special motion behavior.
B
99
S
35
G
29
Posts: 3,139
Reputation: 28,421

Post » Sat Jan 25, 2014 10:52 am

[QUOTE=Ethan] This is what i was originally using for a game i was making a while ago but i found a bug in the way it finds paths, you can check my thread here http://www.scirra.com/forum/turn-based-strategy-like-advance-wars-devlog_topic74453_page1.html

I PM'd the author but didn't get a response.

I think rexrainbox does another pathfinding object though.[/QUOTE]

Sorry to hear you had to stop working on your game, that sucks :( Was the issue only with adding different terrain costs to the pathfinding? Because I don't plan to use terrain costs for my project, I just want grid-based pathfinding.

Have had a bit of a play with the Rez one and it seems to be working well for what I need, and I'd rather use a plugin if possible (I downloaded yours and Rojohound's example but I'd have no idea where to start tinkering with it!) Did you have any other issues with Astar Pathfinding apart from terrain costs?
B
15
S
4
G
1
Posts: 286
Reputation: 1,988

Post » Sat Jan 25, 2014 1:36 pm

Try this - just uses the built-in pathfinding behaviour set to a grid. Someone with better skills than me might be able to improve it :)

https://dl.dropboxusercontent.com/u/106247621/LinearPathfinding.capx
B
15
S
4
G
1
Posts: 286
Reputation: 1,988

Next

Return to Construct 2 General

Who is online

Users browsing this forum: boybacteria, higher2003, MadSpy, TheRealDannyyy and 16 guests