How do I use pathfinding on a tilemap?

0 favourites
  • 4 posts
From the Asset Store
Units do not overlap each other and use different ways if there are several free ways.
  • Hi,

    I've created an island layout using a tilemap and I want to use pathfinding so that enemies on the island can find me. The only problem is that the pathfinding ignores the shape of the island and charges across the sea as the most direct route. I've used a background layer as the sea and have tried setting that to solid or as an obstacle, but then the enemies don't find a path.

    So in essence, how do I limit pathfinding behaviour to just the tiles on a tilemap and not cross the sea please ?



  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Did you try fencing off the island with invisible solid sprites so they can't find a path off the island? If your sea is covering the entire level in the background then setting that to an obstacle won't work. I made a theme park game where the people had to find a path on pavement but not on grass, the grass was set to solid. You can set the sea to solid if you tile or fence it around the island but not if it is underneath them.

  • Thanks for the reply Plinkie. I did consider this option, but it's a real pain following the shoreline as the island is not limited to the viewport and covers most of the layout. Looks like I've got a bit of colouring in to do ☹️

    Thanks again for the reply.

  • hypnorabbit

    Take a look at the demonoire demo, it uses 2 separate tile maps. One invisible one for collisions and another without collisions for the background. It's quite a flexible technique, if a little time consuming. But at least you can use flood fill etc. on large blocks. It's also easier if you put them on separate layers, to make selection easier.

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