How to see if a transform is visible without a camera

I am having trouble making an enemy script that will check whether the player is visible or obstructed from its point of view. If it is obstructed, the enemy will roam aimlessly. if it is visible, the enemy will move toward the player.

The typical (and simplistic) solution to this problem is to do a Physics.Raycast() from the enemy’s position towards the player’s position. If it hits, and if the hit.collider.name is ‘Player’, then you know the pivot point of the enemy can see the pivot point of the player. A more complete solution is to Raycast() from the position of the ‘eyes’ of the enemy to the corners of the mesh.bounds (transformed into world space) of the player. While also not perfect, it allow the enemy to see when only a small part of the player is visible.

var player: Transform;

function Update () {
        var hit : RaycastHit;

	if (!Physics.Raycast (transform.position, player.position - transform.position, hit) && hit.collider.name == "Player") {
		Debug.Log("The enemy is seeing the player");
	}
} 

I don’t know how far you want to take it, but you may also want to check the angle between the enemy forward and a vector between the enemy and the player. If it is above some threshold, then the enemy is facing away from the player.