Hello Guest

Author Topic: 3 Questions  (Read 6761 times)

brutang

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 9
    • View Profile
3 Questions
« on: September 06, 2014, 05:37:44 am »
I searched but couldn't find a solid answer on any of these regarding TileMaps:

1) is there an easy way to reorganize the palette? The stuff I slice up and import ends up all over the place rather than organized how I have my tilemap set up. The only answer I found was from 2013 and said it would be patched in, but I can't seem to figure it out.

2) Any way to do an animated tiles, such as flowing water or sparkles in gems in the ground, etc? (i mean adding an animated sprite/texture to the palette, not "how do i draw this")
Edit: http://2dtoolkit.com/forum/index.php/topic,4113.0.html is the answer to that - animated sprites then just replace a tile with the prefab of the animated sprite.

3) Can the color channel be changed at runtime? IE what if I had the entire level painted black.. could I use a torch to paint it white around the area, then revert to it's default color when the torch is out of the way.. almost a way of doing lighting/shading?
Edit: Looks like http://2dtoolkit.com/forum/index.php/topic,4216.0.html is what I was looking for. Is this an expensive way of doing lighting? In any case the blood splatter thing will be very cool and I was looking for that as well.

Hopefully these aren't obvious or answered before, I dug around for a bit before posting.

Thanks.
« Last Edit: September 06, 2014, 03:18:25 pm by brutang »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: 3 Questions
« Reply #1 on: September 07, 2014, 12:04:53 pm »
1. No, but you can use the scratchpad feature to reorganize your palette any way you like.

2. Use animated sprites sporadically, I wouldn't use them if you had animated tiles every other tile... A shader will probably work a lot better, you can simply override materials on sprites easily enough.

3. It not massively expensive - the most expensive thing with tk2d tilemaps is generating colliders, so if you're not doing that you're fine - you can tweak partition size to limit the amount of recomputing that needs to be done.

brutang

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: 3 Questions
« Reply #2 on: September 07, 2014, 04:58:26 pm »
Thanks.

As a followup, is there a way to decrease the intensity of the color of a tile painted at runtime? tileMap.ColorChannel.SetColor (x, y, myColor); sets the entire tile to that color whereas if I were to manually set the intensity to, say, 20 and click the tile once it more tints it than colors it completely.

Edit: Also, any way to get OnTriggerEnter2D to work with a tilemap collider? OnCollisionEnter2D works great. Triggers i can't figure out.

One more question: is there a way to fill the colliders generated by the tilemap mesh in? Or will they only ever be edge colliders? I just run into issues with ground checks and stuff like this: http://screencast.com/t/OSkvN3o2hGu where colliders end up underneath the edge collider whereas if it were a box collider that couldn't happen. I totally understand if they can't be since it's generated based on the mesh.
« Last Edit: September 07, 2014, 05:44:22 pm by brutang »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: 3 Questions
« Reply #3 on: September 08, 2014, 12:37:07 pm »
You'll need to blend the colors yourself if you want to incrementally tint it, eg. Color currentColor = tilemap.ColorChannel.GetColor(x,y), then blend it with your color and assign it.

OnTrigger2D wont work, as it is an edge collider, it doesn't have a "volume". We don't plan on changing it to anything else at the moment, the overhead of using different collider types is very very large, especially for larger tilemaps.

There is a much better way to find out if you're inside a tile, just use tilemap.GetTileIdAtPosition - that returns the contents of the tile, and in your case the colliders are rectangular. Try using that over a raycast / trigger - performance will be way way faster than those anyway as its just an array lookup.

brutang

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: 3 Questions
« Reply #4 on: September 08, 2014, 03:39:58 pm »
Do that instead of using a raycast as a ground check or what?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: 3 Questions
« Reply #5 on: September 08, 2014, 04:12:30 pm »
Maybe - more as a means of finding out if you're colliding with / inside something. If you're inside something, you can always backtrack and raycast to find out where you've hit it.

brutang

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: 3 Questions
« Reply #6 on: September 08, 2014, 04:55:09 pm »
gotcha, thanks :)

awesome tool by the way, 10 months into developing my game and just started using 2dTK and it's got me excited to keep going.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: 3 Questions
« Reply #7 on: September 08, 2014, 05:03:48 pm »
Awesome! Great to hear that.