enemy ai detection

Hi all
when we place an enemy in home.how can stop it from detection player when player is out of home or other side of wall?
Thankful.

Use raycasting to shoot a ray from the enemy to the player, and check to see if the ray collides with anything between the enemy and the player to determine if there is a wall in the way.

i used it but this dont print a;

if (Physics.Linecast (transform.position, playerTransform.position,out hit))
		{
			print("a");
			return (hit.transform == playerTransform);
			
		}

any one hasnt any idea?

Do you have to use an “out” parameter? What happens if you remove it and make “hit” a normal variable?