Search Unity

Question Making multi-part character transparent

Discussion in '2D' started by Michoko, Mar 25, 2021.

  1. Michoko

    Michoko

    Joined:
    Apr 15, 2017
    Posts:
    24
    Hi!

    I use characters made of a gameobject, and a dozen children (each child corresponding to a body part, that I animate separately). I'd like to make the characters half-transparent in some cases.

    I tried the option of going through all children of the character object, and setting the color to half-transparent. But the result is not great, as each part blends with parts behind it, so it creates a kind of "x-rays" effect. I'd like to have the character globally transparent, as if it was a single sprite, not a series of overlapping half-transparent layers.

    I'm still new to Unity, especially shaders, and I suppose I would need to use one to obtain the effect I want? However, I don't know a lot about this, and I would appreciate some detailed tips about the options I have to achieve this effect. Thank you very much for your help!
     
  2. rarac

    rarac

    Joined:
    Feb 14, 2021
    Posts:
    570
    I had the same problem and I asked here and the short answer is that it cannot be done

    you have to use texture2d.setpixel to combine all sprites into 1 so you have only 1 sprite
     
    Michoko likes this.
  3. Michoko

    Michoko

    Joined:
    Apr 15, 2017
    Posts:
    24
    Thank you for your reply. It's a bit disappointing that something as obvious in other 2D game engines is so tricky to implement with Unity. I even thought of using a RenderTexture to render my character to a simple quad, then change the quad opacity. I plan to release the game on mobile though, and I'm concerned about performance if I do that on every character.

    I think now I may have to bake the various character animations into spritesheets, and use simpler sprites, which defeats the purpose of skeletal characters. But at least it might be the simplest solution, provided it doesn't eat too much memory...