2D Toolkit Forum

2D Toolkit => Support => Topic started by: codejoy on June 01, 2015, 11:29:45 pm

Title: Making parts of the tile map semi transparent to things behind it.
Post by: codejoy on June 01, 2015, 11:29:45 pm
I have no idea how to do this in unity.  Basically I have water tiles in my tile map that I want to actually render on a different layer which I can do that, but it obviously covers up anything behind it.  Instead I want it to alpha blend so it acts semi transparent.

No ideas where to start on this.  If it had a sprite renderer i could figure it out since it is a 2d game, but the way the tilemaps are built with just a mesh renderer in unity5 I am not sure how to go about doing this.


Title: Re: Making parts of the tile map semi transparent to things behind it.
Post by: codejoy on June 02, 2015, 12:03:58 am
I think I figured it out, I can goto the right tile map Chunk 0 0 for instance and goto the atlas0 material.  The shader i have as sprites diffuse but i can change the tint alpha and it works but it changes everything regardless if its a diff tile map so not sure how to stop this, create another sprite collection same image though?


Title: Re: Making parts of the tile map semi transparent to things behind it.
Post by: unikronsoftware on June 03, 2015, 09:00:43 pm
Draw it in the same sprite collection but make the texture semi transparent - that should do the job shouldn't it. You can draw this in a foreground layer and it'll appear semi transparent.
Title: Re: Making parts of the tile map semi transparent to things behind it.
Post by: codejoy on June 04, 2015, 11:26:45 pm
Not sure what you mean by drawing it in the same sprite collection.


This might be a dumb question but:  Can I add multiple sprite/textures to a collection or have different versions of the sprite in a collection?  I need to study up on the sprite collections all I know bout them is what was presented in order to make tile maps briefly, I never dug deep into what they can do.

Title: Re: Making parts of the tile map semi transparent to things behind it.
Post by: codejoy on June 04, 2015, 11:37:26 pm
So yep the right side has atlas0 material, its been so long since I created the original sprite collection and tilemap that I forgot where atlas0 was created at. 

Title: Re: Making parts of the tile map semi transparent to things behind it.
Post by: unikronsoftware on June 05, 2015, 12:39:51 am
You can add teh same texture twice in a sprite collection. It'll only appear in the atlas once.
Title: Re: Making parts of the tile map semi transparent to things behind it.
Post by: codejoy on June 05, 2015, 01:18:54 am
So is the alpha on the texture I have to change it?   I was changing the material ...do I just make another sprite collection?
Title: Re: Making parts of the tile map semi transparent to things behind it.
Post by: unikronsoftware on June 06, 2015, 11:08:33 pm
Just changing the texture will do it, but if you want to change materials, check out the docs here -
http://2dtoolkit.com/docs/latest/tutorial/multiple_materials_in_a_sprite_collection.html
Title: Re: Making parts of the tile map semi transparent to things behind it.
Post by: codejoy on June 06, 2015, 11:19:31 pm
Ahhh thank you for that link I have done this before and I couldn't remember how!!!  Though I had something cool happen:

I had my artist deliver my tiles as individual sprites not from a sprite sheet.  creating a collection required no sprite sheet first I could just drag all the tiles in there.  Was a bit quicker than creating a sprite sheet.

I did use the multiple materials way, was changing the texture more efficient?  I wasn't sure how to do that, unless I have to do that in a separate program but it didn't seem that unity gives me any options to adjust the alpha except for a alpha from greyscale in an advanced texture type, is that what you were meaning?

Title: Re: Making parts of the tile map semi transparent to things behind it.
Post by: unikronsoftware on June 06, 2015, 11:28:04 pm
You can't change the texture alpha in Unity, it has to be done externally. But it will be more efficient because you don't need an additional material.