Hello Guest

Author Topic: [paid] Tilemap pathfinding  (Read 48056 times)

dotty

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 65
    • View Profile
[paid] Tilemap pathfinding
« on: March 17, 2013, 03:53:53 pm »
Hello all.

I've been trying to implement pathfinding using 2dtk's tilemap system and I'm failing miserably. I've tried to write one myself (and failed) and I've tried to implement arongranberg 's aStar plugin (and failed). I'm getting frustrated, so if anyone would be interested in doing this for me, I'm sure we could come up with a fair price.

If you're interested, drop me a PM.

Just a couple of needs.

1) The package needs to scan through ALL layers and find collidable tiles.
2) Needs to be lightweight and quick
3) Needs to support quite large maps 512x512
4) Needs to support multiple tile sizes (32x32, 64x64, etc)
5) Only needs orth tiles (no need for iso tiles)
6) Ideally collision arrays need to be saved so they don't get created on runtime.

I think that's about it at the moment, again if you're interested drop me a PM.

x8105

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 85
    • View Profile
Re: [paid] Tilemap pathfinding
« Reply #1 on: April 24, 2013, 09:03:50 am »
I would be highly interested in this too,,,on a side scroll basis.

jakecattrall

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: [paid] Tilemap pathfinding
« Reply #2 on: May 21, 2013, 03:11:49 pm »
Hi there,
I just got here and will check 2dtoolkit out tonight.

I think this (https://github.com/krazyjakee/jQuest/blob/master/src/astar.js) is what you're looking for, however, I haven't integrated it into 2dtk yet. Give me some time and I'll let you have it.

pythagoras123

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: [paid] Tilemap pathfinding
« Reply #3 on: June 28, 2013, 12:41:37 am »
Whatever happened to this thread, I would love to know whether anyone ever found a solution to get pathfinding working with tk2d tilemaps.

dotty

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 65
    • View Profile
Re: [paid] Tilemap pathfinding
« Reply #4 on: July 03, 2013, 11:37:10 pm »
I got it working with Simple A* (http://forum.unity3d.com/threads/164003-Released-BFGames-Simply-A*-Pathfinding!) if you're interested?

pythagoras123

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: [paid] Tilemap pathfinding
« Reply #5 on: July 04, 2013, 12:20:34 am »
I am indeed and curious to see how you did it.
I have done some experiments too with simple A* but wasn't satisfied with the result. One of my main problem is that my tilemap is huge (930x326 tiles) with a tileset of 512 different tiles. I am trying to avoid generating colliders or prefabs for each and every tile.

dotty

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 65
    • View Profile
Re: [paid] Tilemap pathfinding
« Reply #6 on: July 05, 2013, 10:03:37 am »
I ended up editing simple a* to run my own method a create an array of nodes. I essentially looped over ever tile, if it had a collider mark it as unwalkable, if it doesn't mark it walkable. I then pumped that array into simple a* and let it run it's own pathfinding. It worked well for me. I had a map about 100x100 tiles, each tile being 32px X 32px. I had about 50 pathfinders running without a hitch. This was on i7 retina macbook pro.

I'll send the code across later when I get home from work.

pythagoras123

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: [paid] Tilemap pathfinding
« Reply #7 on: July 05, 2013, 04:50:59 pm »
Thanks, that's very interesting ! I'm looking forward to see how you did that.

dotty

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 65
    • View Profile
Re: [paid] Tilemap pathfinding
« Reply #8 on: July 05, 2013, 09:05:06 pm »
Obviously import simple A *, then create a script called PathFinder2DTileMap.cs and add the code in the link below.

All you need to do is set Toolkit2DTileMap to a tk2dTileMap object and it should do the rest (if you click "Draw Map In Editor", you'll see the red areas that aren't walkable, and green which are).

You can then use simple A *'s Pathfinding functions. Be warned, this script was created for a 32x32 tile, and simply selects tiles if they have a collider or not, so you might need to tweek it a lil.

http://pastiebin.com/51d7253305569

pythagoras123

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: [paid] Tilemap pathfinding
« Reply #9 on: July 06, 2013, 01:33:47 pm »
Many thanks ! I'll try that as soon as i get back.

JBabz

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 42
  • @joe_babz
    • View Profile
    • Zombit on Facebook
Re: [paid] Tilemap pathfinding
« Reply #10 on: August 22, 2013, 06:15:45 pm »
I'm trying this, and it returns all of my tiles as having an ID of -1. Any ideas?

dotty

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 65
    • View Profile
Re: [paid] Tilemap pathfinding
« Reply #11 on: August 23, 2013, 12:22:39 pm »
-1 implies the tile has no collider.

However, I know the tilemap api/system has been recently updated, so the code might need updating. I'll take a look at it over the weekend and try to update it as soon as possible.

Do you have multiple layers? That could be the issue here.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: [paid] Tilemap pathfinding
« Reply #12 on: August 23, 2013, 12:43:30 pm »
The API update shouldn't have affected that, I don't think - it still returns / stores the same values.

Artheus

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: [paid] Tilemap pathfinding
« Reply #13 on: November 14, 2013, 07:32:39 am »
For some reason, I can't get the Draw Map in Editor option to work.

Ok, you have to look at the editor window while the game is running.
« Last Edit: November 14, 2013, 10:09:18 pm by Artheus »

Artheus

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: [paid] Tilemap pathfinding
« Reply #14 on: November 15, 2013, 11:07:46 pm »
It doesn't seem to be 100% accurate.  Walkable nodes will still connect to non-walkable nodes like this (the gray walls have colliders on them):



I'm trying to figure out why but has anyone else encountered this problem?
« Last Edit: November 15, 2013, 11:25:29 pm by Artheus »