Unity. Plane with sprite clips in front of ProBuilder object depending on distance of player. Might be a shader problem

Viewed 215

I am making a game that uses 2D sprites in a 3D world. I tried to do this by putting the sprite in a material and putting that material on an plane, and choosing the shader option "Transparent (UI/Lit/Transparent)". This works great in the sense that it hides the plane, shows the sprite and interacts with lighting.

But this method makes the objects (the trees in the picture) clip in front of the ProBuilder object (the chain linked fence in the picture), when th player gets too close.

The solution I found was using the Transparent (Unlit/Transparent) shader. My guess is that this solves the problem because there is no 'UI' in the shader's name. The problem is though, that this also is "Unlit", which means that the trees do not interact with lighting.

I have also tried this by making a ProBuilder object and deleting all but one face, but this had the same effect as the example given in the pictures.

How do I make the object show the sprite with the transparent parts invisible and with it interacting with light?

Further Distance

Closer Distance

1 Answers

I solved it. I put the shader back to 'standard' and then changed the rendering mode to 'cutout'.

Related