The NavmeshAgent component and the EnemyMove script are responsible for the enemy’s movement and pursuit of the character.
For the NavmeshAgent to work, you need to bake the scene:
Mark all objects in the scene as Navigation Static
Go to [Window -> AI -> Navigation->Bake]
In the EnemyMove script, set the player’s visibility distance and the distance at which the enemy will stop and attack the player.
When the player is in sight, the enemy will pursue him. If the distance is less than the specified distance to attack, the enemy will attack the character.