How do I create Distance for Each Tile with Pathfinder?

0 favourites
  • 8 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • Hello!

    I'm Indie Game Developer who worked with Clickteam Fusion during 15 years, and I decided to switch on Construct 3 now since the possibility are limitless.

    I worked on a Tactical RPG Rogue Lite and I'm trying to recreate it on Construct, it's a bit difficult but since the logical is a bit the same than CF, I'm hopefull :p

    I'm really surprised how the Pathfinding objet is really easy to use, but I'm not sure if I doing the good way for a system.

    I would like to have the distance of each tile for an Event, like Fire Emblem :

    Then I'm able to had path on all the cases that are in the range of the Event.

    On Fusion, I added an Array, and Created Loops that compare all the cells to know the distance with an incremented value.

    It's a bit long and I'm not sure to be able to do it on Construct.

    I just wondering if there is a better option, or If I have to do the same?

    Thank you in advance, and sorry for my English, I'm French.

  • If this is a tile-based game, I suggest using EasyStarJS instead of Pathfinding.

    It works with tilemaps and there is PathCost expression which you can use to get the path distance to a specific tile. It's also much faster than Pathfinding.

  • Thanks dop2000 that's perfectly what I wanted, but saddly that's really complicate to use it... I guess I'm not ready for that kind of system :/

  • I don't think you need pathfinding at all for a tile based grid with short ranges, especially if you are going to do it one step at a time.

    dropbox.com/s/v56jw51ktwd70mj/bfsfloodfillexample.c3p

    It's called a breadth first search, basically just a portion of the a* pathfinding algorithm. It will work with obstacles fine, but do note that it becomes exponentially less efficient the more steps it has to calculate, which is why more advanced pathfinding algorithms such as a* were developed. Both the official pathfinding plugin and easy star library use the a* algorithm as a base.

  • Thank you Oosyrag, that's work great but I'm not sure the logic will work with obstacles without using pathfinding? Since it need to calculate a path if an obstacle is next to the player position.

    Do you think you can try to add obstacles to your system, if you are time?

    Thanks a lot!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Updated the file.

    You simply add a condition to not update the value of the corresponding array coordinates if it is what you define to be an obstacle. In this case I made it so that it only runs if the tile to be updated is not tile 2.

  • That's perfect, and so much understandable than using Pathfinding scripts, thank you so much!!

  • Thanks dop2000 that's perfectly what I wanted, but saddly that's really complicate to use it... I guess I'm not ready for that kind of system :/

    It's not that complicated, you can download an example project (capx) from this post:

    construct.net/en/forum/extending-construct-2/addons-29/behavior-easystar-js-96215

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