Maybe the question didnt show much... but what I'm trying to do is e.g. if I'm in a train platform with two floors overlapped, or in a place where I'm blocked by some obstacle to see my char. from my view. I want to let my character be visible but have how should I say, have lines? of the obstacles overlapped a bit so i can have an impressing there is an obstacle but you're seeing your char. through, kinda like half-visible, kinda like gradation.

tl;dr - I want to see my character who is normally should be blocked the view from my POV to be visible, while also making the player to see that there's something between the character and the POV. is there a method I can check?

using dots to create this via photoshop.

  • \$\begingroup\$ Something like the units that are behind the castle in this image? \$\endgroup\$ – Quentin Apr 21 '17 at 8:57
  • \$\begingroup\$ not really, um... same like gradation I guess? the whole characters should pop out. ugh couldn't remember any games that could help explain this :( \$\endgroup\$ – MrSolid51 Apr 21 '17 at 9:03
  • \$\begingroup\$ I'm sorry but I don't get what you mean. It would help a lot if you could find a screenshot from another game or make a quick mock-up of what you envision :) \$\endgroup\$ – Quentin Apr 21 '17 at 9:08
  • \$\begingroup\$ the one on the far left. need something to make that effect on the image. \$\endgroup\$ – MrSolid51 Apr 21 '17 at 10:59
  • 1
    \$\begingroup\$ @MrSolid51 That's called "dithering". It really fell out of fashion since we have alpha transparency, even for spriteart games. That's maybe because it looks so much more ugly on a LED display than it looks on a CRT display. \$\endgroup\$ – Philipp Apr 21 '17 at 11:20

When the sprite is obscured by an object, you could make that object transparent:

enter image description here

You can make a sprite transparent in Unity by setting the alpha-value of the sprite color.

Color tmp = sprite.GetComponent<SpriteRenderer>().color;
tmp.a = 0.5f;
tmp.GetComponent<SpriteRenderer>().color = tmp;

Another option is to just draw the outlines when the character is behind something. This looks a bit cheaper, but will usually cause less visual clutter:

enter image description here

This requires that you make two versions of every asset you want to be able to become transparent. Simply switch out the sprite image of the renderer.

But how do you detect when you need to do this? There are two options for this I would consider.

  1. When the number of objects which are supposed to behave like that is limited, you could give each of these objects a "isTrigger" collider and add a script to them which implements OnTriggerEnter and OnTriggerExit to make the sprite transparent/opaque when the triggering object is the player-character.
  2. When you want objects on the over-layer to behave like that in general, you could use a raycast from the player-character in its Updated method to detect if something is above it and make that thing transparent.
  • \$\begingroup\$ oh cool. I'll need to look more onto this stuff since i'm not working on this part yet(and I'm a beginner on these stuff). still thank you for the help. \$\endgroup\$ – MrSolid51 Apr 23 '17 at 10:40
  • \$\begingroup\$ and one more question, about what you said about dithering. then what's used more commonly nowadays? \$\endgroup\$ – MrSolid51 Apr 25 '17 at 8:01
  • \$\begingroup\$ @MrSolid51 32bit color depth and alpha transparency. \$\endgroup\$ – Philipp Apr 25 '17 at 8:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.