How to navigate NPC and let them attack when they see the enemy?

Hi! I want to know how can we make NPC to navigate to player and when they see the Enemy , I want them to attack the Enemy. We can calculate by the distance but it doesnt mean they are seeing the enemy.
Can we even do this? Thank you!