How to make an enemy in a platformer game not see through a wall?

Hello everyone! Please help! I made an enemy with a sprite of view. The enemy can detect the player, but it can also “see” through walls. How can I fix this?

You can use a raycast from the player to the enemy that ‘spotted’ them and see if it hits a wall object. There are raycast tutorials and raycast examples to help understand how they work

MrMen thank you! )))