Make raycast ignore player, if a wall is in the way.

I have a enemy with a raycast shooting out its eyes. When the player touches the raycast, its printing “I SEE U”).
But i want it so when a wall is in the way, its not printing “I SEE YOU”.
Just like in real life. You cant see your friend, if there is a wall between you.
I dont want the enemy to see me, if there is a wall between us.

Here is my script for now.

using UnityEngine;
using System.Collections;

public class RaycastForward : MonoBehaviour {
	public bool spotted = false;

	// Update is called once per frame
	void Update () {

		RaycastHit hit;

		Vector3 forward = transform.TransformDirection (Vector3.forward) * 10;
		Debug.DrawRay (transform.position,forward,;

		if(Physics.Raycast (transform.position,(forward), out hit)) {
			Debug.DrawLine (transform.position, hit.point,;
			Debug.DrawRay(transform.position,forward * 19,;
		if(hit.transform.gameObject.tag == "Player") {
			print ("I SEE U");

Ok so i found out what was wrong. My player had the tag “Player”, but then all the childrens also react. In that case i had a object with a biiiiiig collider, whichwent through the walls.