I am wanting to create the Diablo 3 effect of objects visibility toggling on and off when passing behind. I have this so far…
var target = gameObject;
function OnTriggerEnter() {
// toggle visibility:
renderer.enabled = !renderer.enabled;
}
I know this shouldn’t work, and would like to know what to do to make it work. I am using a script…
function Update() {
if (Input.GetKeyDown(KeyCode.Z))
{
// toggle visibility:
renderer.enabled = !renderer.enabled;
}
}
This works fine, but I want it to work off a trigger not a key.