Make AI shoot when player is in line of sight

Hello,
I am working on a platformer in which we use guns, frags, etc.
How can i make AI/computer shoot only when player comes in line of sight
. If there is any object breaking the line of sight of AI then it should not shoot/fire and this applies for both directions.
Please help
I am working on a platformer in which we use guns, frags, etc.
How can i make AI/computer shoot only when player comes in line of sight

Please help