Linecast always returns true

In my FPS when I look at monster game object, I want to do action 1. And if I don’t look at him, I want to to action 2, but it always excecute action 1. Can’t understand, why?

public Transform player;
public Transform monsterFriend;
void Update()
	// do action №1
	// do action №2

Where is pivot point at your character and the enemy. It seems that pivot point to be below in feet. Then when using Linecast you will have “collision” with the ground. Most likely you should change position of Vectors, for example, to a half of height of the character. Let’s say that height equals 1.6, then:

 if(Physics.Linecast(player.transform.position + new Vector3(0, 1.6f/2, 0),
     monsterFriend.transform.position + new Vector3(0, 1.6f/2, 0))) {
  // do action №1
 } else {
  // do action №2

I hope that it will help you.