- Home /
Light and 2D Sprite overlapping issue
I'm having a problem with lights and 2D sprites. The issue is that when I use the point light and overlap with another sprite I can see through it.
So the sprites become way too transparency when using the Sprite/Diffuse shader. Is there any other way to fix this beside changing the z position or the order in layer? Is there a way to fix this by making a custom shader?
Below is a picture to make it more clear what I mean:
unityproblem.png
(68.0 kB)
Comment
Answer by Panasenko · Apr 24, 2017 at 03:03 AM
private SpriteRenderer spriteRenderer;
// Use this for initialization
void Start () {
spriteRenderer = GetComponent<SpriteRenderer>();
spriteRenderer.sortingLayerName = "Enemy";
spriteRenderer.sortingOrder = Random.Range(1,100);,Hi, I've had the same issue so in Enemy script, I've done this:
private SpriteRenderer spriteRenderer;
void Start () {
spriteRenderer = GetComponent<SpriteRenderer>();
spriteRenderer.sortingLayerName = "Enemy";
spriteRenderer.sortingOrder = Random.Range(1,100);
So that's added to every enemy different layer number.