Changing render mode during runtime

Hi! I’m in the process of making my first game, and I’m running into an issue I can’t solve.

The scene I’m working on is a 3D room with a top-down perspective, using a 2D sprite as the player. Since the front wall of the room will obscure the player when you walk to the bottom of the screen, I want to make the wall change to the Fade render mode when you walk toward it to make the player visible, while making it clear the wall is still there.

Looking through Unity forums and documentation, it seems you enable the keyword “_ALPHABLEND_ON” to use the Fade render mode, but when I did this, it didn’t work. (Even worse, other variations of my code caused my sprite to clip through the wall and fall into the void below.)

Here is my current code:

public class FadeOut : MonoBehaviour {

    [SerializeField]
    private Transform player;
    private Material standardShader;

    // Use this for initialization
    void Start ()
    {
        standardShader = GetComponent<Renderer>().material;
    }

    // Update is called once per frame
    void Update ()
    {
        if (player.position.z >= 7.78f)
        {
            standardShader.EnableKeyword("_ALPHABLEND_ON");
        }
    }
}

I’ve looked everywhere online, and I’ve tried a few of the solutions other people have offered, including this oft-cited answer, but nothing seems to work. (I’m a Unity beginner, so I’m definitely just implementing that code wrong, I’m sure.)

This seems like it should be easier to execute than it is, considering how easy it is to modify everything else in a material.

Can anyone help explain how to do this?

I’m bumping this because I didn’t get a response!