2D Toolkit Forum

2D Toolkit => Support => Topic started by: adam on April 12, 2014, 12:46:45 pm

Title: Isometric Tilemap colliders
Post by: adam on April 12, 2014, 12:46:45 pm
What is the best way to check if the tiles a building occupies are colliding when you go to build a new building with an isometric tilemap.

Do you add a isometric box collider?
Add invisible tiles under the building and use gettileat?

would love to know the fastest and best performance way to check thanks.
Title: Re: Isometric Tilemap colliders
Post by: unikronsoftware on April 14, 2014, 05:09:47 am
Use GetTileIdAdPosition - that is way way faster than any physics based solution.
Title: Re: Isometric Tilemap colliders
Post by: adam on April 14, 2014, 07:11:14 am
what if you have buildings that are 3x3 or 4x4 is this still the fastest way, checking 9 or 16 tiles or are colliders going to be faster?
Title: Re: Isometric Tilemap colliders
Post by: unikronsoftware on April 14, 2014, 07:44:08 am
It should still be faster, but to be honest checking so few things isn't going to make a great deal of difference either way.
Title: Re: Isometric Tilemap colliders
Post by: adam on April 14, 2014, 01:55:42 pm
we are currently using prefabs for buildings and initiating them using
currentBuilding = ((GameObject)Instantiate(b)).transform;
and then moving them with
currentBuilding.position = new Vector3(p.x,p.y,-90);
the problem is using gettileidatposition always returns -1, Is there something we are doing wrong?
Title: Re: Isometric Tilemap colliders
Post by: unikronsoftware on April 14, 2014, 06:50:29 pm
If there isn't a tile at the position, it should return null. Get Tile Id at position should return the tile at a particular position. There are other functions to return the tile x & y coordinates, and then another function to resolve that back to the world position - this will snap the position to a tile boundary, if thats what you need.