I have a game object with a halo effect, and I basically want to enable it when the camera is looking at it.
I tried this and numerous variations:
public void Update () {
RaycastHit hit;
if (Physics.Raycast(transform.position, transform.forward, out hit, 10)) {
hit.collider.gameObject.GetComponent<Halo>().enabled = true;
}
}
But it was to no avail. Any ideas on how to do it?