I'm trying to make a isometric game. I want to make it so that when the player goes behind a wall, the wall's alpha goes down.
How do I go about doing this?
I have this code that I made, but I don't understand what's wrong with it.
I already have the wall that's meant to disappear on the "Wall" layer.
using UnityEngine;
using System.Collections;
public class WallAlpha : MonoBehaviour {
public LayerMask mask =LayerMask.GetMask("Wall");
void Update() {
if (Physics.Raycast(transform.position, transform.forward, 100, mask.value))
{
transform.GetComponent<Renderer>().material.SetColor("_Color", new Color(1,1,1,0.1f));
Debug.Log("Something in the way");
}
else
{
transform.GetComponent<Renderer>().material.SetColor("_Color", new Color(1,1,1,1.0f));
Debug.Log("Nothing In the Way!");
}
}
}