Hello Guest

Author Topic: Painting tagged tiles  (Read 3870 times)

Dunkelheit

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 12
    • View Profile
Painting tagged tiles
« on: December 18, 2013, 02:29:28 pm »
I bought this asset specially to build my level using tileset map instead to use like 4.3 map does (it isn't a tileset map, at all), however I found a problem. I can't tag a tile and I need it, because to my player char jumps need to use linecast to check the tiles tag, if the tag is "grounded" so he can jump. Not found a clue in the documents I've saw so far.

Any suggestion?

Thanks!

Dunkelheit

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Painting tagged tiles
« Reply #1 on: December 18, 2013, 04:47:23 pm »
I was changing one thing here and I realize a solution, but unfortunately I had to create a prefab to achieve this.

- Create a sprite of selected image;
- Add Box Collision2D (4.3+ Unity);
- Custom your layer or tag as well (my intention was that);
- Drag this object to your project as prefab;

- Now go to tileset map properties and navigate to "Data" tab;
- Select your appropriate tileset and at the bottom, drag out your prefab there;

Now the tileset wil behave the prefab behavior.

Dunkelheit

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Painting tagged tiles
« Reply #2 on: December 18, 2013, 04:48:13 pm »
If you have another way to achieve it, please let us know.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Painting tagged tiles
« Reply #3 on: December 19, 2013, 12:03:35 am »
You can't tag a tile because it doesn't exist at runtime - the tile map system merges tiles to create a large composite mesh for efficiency. You can however, ray cast on to the ground underneath, then use tileMap.GetTileIdAtPosition to find out what tile you're standing on and react appropriately. If you're just looking immediately underneath, you can skip the ray cast and simply GetTildIdAtPosition(playerPos - halfTileHeight).

Dunkelheit

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Painting tagged tiles
« Reply #4 on: December 19, 2013, 12:24:51 am »
So I have to continue to use the way I mentioned before. When I get a spare time I'll take a look at this solution you have said it.