[Suggestion] Grid-based pathfinding behaviour

0 favourites
  • 14 posts
From the Asset Store
Snap to visible grid - perfect solution for any game genre
  • 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 <img src="smileys/smiley4.gif" border="0" align="middle" /> 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.

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

    <img src="https://dl.dropboxusercontent.com/u/106247621/pathfindexample.jpg" border="0" />

    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!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Definitely +1 for this!!

    Even the 4-direction option does�t really work well.

    It seems to swim a little which looks absolutely stupid on walking enemys!

  • 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.capx

  • +1

  • 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:

    construct.net/en

  • 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.

  • It would be nice when new beta comes with special motion behavior.

  • 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 construct.net/en

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

    I think rexrainbox does another pathfinding object though.

    Sorry to hear you had to stop working on your game, that ***** :( 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?

  • 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 :)

    dl.dropboxusercontent.com/u/106247621/LinearPathfinding.capx

  • The existing pathfinding behavior is already tile based and can do exactly this. If you don't like the default way it moves objects, you can make your own - the behavior can return a list of the path nodes.

  • Thanks Ashley, yeah turns out I was just being lazy <img src="smileys/smiley4.gif" border="0" align="middle" />... think I've got it worked out now.

  • Can u pls post an example capx?

  • Here you go:

    dl.dropboxusercontent.com/u/106247621/LinearPathfinding.capx

    Also works fine with diagonals turned off.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)