Isometric Tilemap 2D Collision bounds

I'm working on a tilemap project that needs pathing (would be great if you could use a navmesh with a procedurally generated tilemap BTW).

I was using an orthographic tilemap and everything was working great by setting my A* grid to the Tilemap Collider 2D bounds. When making the conversion to isometric it doesn't seem to work. Sizes and the bounds center is all off.

Anyone have any tips on how to get an isometric tilemap bounds?

Bounds on the isometric tilemaps are cell bounds, not in world space. To translate from cell space to world space use tilemap.CellToWorld https://docs.unity3d.com/ScriptReference/GridLayout.CellToWorld.html

That's a totally different game object. I'm trying to overlay an a* object over my map and something about the width and height just isnt adding up, though the center point does.

3741079--310669--upload_2018-10-2_9-18-39.png

@zulfajuniadi I’m having a heck of a time getting this to work.

instead of using a bounding box im taking the Tilemap.Size property and then using the tile size i can get something i’m happy with. the new issue is that i cant find the dang center now! any thoughts?

just wish pathing worked out of the box and then i would be nice and happy.

Isn’t the center supposed to be the half width and height of the tilemap size? I’ve also implemented A* on the isometric tilemaps but I’m not using the collider. I’ve just added a new tilemap layer and mark the tiles as walkable or not with respective costs. Will send you a gif once I’m home tomorrow morning.

@zulfajuniadi very appreciated. I'm spending a ton of time on this easy thing. worse is it worked perfect before i switched to isometric.

my current failed attempt to get the center is:
Vector center = new Vector(TileMap.CellToWorld(TileMap.size.x / 2, TileMap.size.y / 2, 0));

Its something silly that's putting it off the course. Would be so much easier if there was a built in bounds or the bounds to the collider worked properly.

Did you create your own A* or use an asset?

I'm trying to use: https://arongranberg.com/astar/
I don't really have a reason other than it's free and works until I feel like the project is far enough to warrant a custom solution.

I'm really considering making an opensource project that creates a few different types of maps(land, town, cave & dungeon) with A* to help everyone like me out once I get the hang of this.

This is what I’ve been working on the last couple of weeks:

Have you tried Tilemap.CellToWorld(tilemapBounds.center) ?

I’ve created my own implementation. Just the basic functionalities of multithreading, scanning, and grid searching with traversable / untraversable tiles and weights. Not nearly as complete as the Astar Pathfinding Project by Aron Granberg.

It’s fast enough and only allocates a few bytes per frame (for thread scheduling). The bottleneck right now is rendering (7.5ms) and animator (24ms) @ 3700 agents as profiled inside the editor. 3-5x speedup on windows player builds.

I’m pretty sure if I were to do this with ECS I could easily have 10,000+ agents running around. Though that would mean that would trade re usability for speed.

Here’s a short explanation video on how it works. Sorry for the background noise for the first 10 seconds or so:

https://vimeo.com/293407030

Do let me know how it goes.

1 Like

@zulfajuniadi Doh, I knew it was something that I should have gotten. Tilemap.CellToWorld(tilemapBounds.center) did the trick. I greatly appreciate the help!!

Your project looks very cool. Hope to see more of it!

1 Like

Good idea! I’m going to do same thing like you. But here I have a question, how should I do to let the non-walkable buliding auto generic a tilemap layer ? Not by manual editing to add a layer.I am going to make a auto generic tilemap into my games, so th
ank you.

The Tile class can instantiate a prefab on start so you could probably do it there using tilemap.WorldToCell and passing the instantiated gameobject’s transform.position.

Thank you for this. And I still want to know how to make or draw the tile sets you made.Like castles and buildings. Were these made by any tools?