How to make the enemy AI (the big one) only attack the player from the front and not go to the sides

I am creating a video game in Lateral Side Scroll and I want the enemy, that is, the big attack in front of the player, but when the player gets very close to the enemy, he tends to go to the sides, how do I just rotate the player and attack but not go to the sides?