Search Unity

How can I turn meshes transparent?

Discussion in 'Editor & General Support' started by Marscaleb, Sep 27, 2020.

  1. Marscaleb

    Marscaleb

    Joined:
    Jan 7, 2014
    Posts:
    1,037
    It looks like my game is going to have issues with objects blocking the camera from seeing the action.
    To resolve this, I'd like to be able to turn certain meshes (or certain groups of meshes) semi-transparent when they player walks into certain areas. But I'm curious how I could do this.

    I'm used to working in 2D where I can adjust a color value on any sprite to adjust its transparency, but I see no such option in the default mesh renderer.
    I suppose its possible to set up a material to do this, but I don't know how to set up such an adjustable transparency in a material, and that would require setting up this system in just about every material within my scene. To top it all off, that would cause some odd rendering effects when you see edges on the other side of the mesh, and have some faces of the same mesh layer on top of each other, creating an uneven effect.
    What I'd really want is some way to make the mesh be drawn like normal, but fade out its view, like it was drawn on a separate layer and that layer had its opacity adjusted, I guess?
    Also I am concerned about running an efficient system to control visibility. If I were to attach a script to literally every object in my scene that exists at waist-height or above that tracks where the camera is on every frame, that would tax the system real fast.

    I'm not sure what options really exist here, so I'm open to different ideas.
    What can I do to make my level geometry become transparent when I need it to be?