Hello Guest

Author Topic: Isometric Tilemap colliders  (Read 5408 times)

adam

  • Newbie
  • *
  • Posts: 8
    • View Profile
Isometric Tilemap colliders
« 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.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Isometric Tilemap colliders
« Reply #1 on: April 14, 2014, 05:09:47 am »
Use GetTileIdAdPosition - that is way way faster than any physics based solution.

adam

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Isometric Tilemap colliders
« Reply #2 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?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Isometric Tilemap colliders
« Reply #3 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.

adam

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Isometric Tilemap colliders
« Reply #4 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?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Isometric Tilemap colliders
« Reply #5 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.