How to make goalKeeper move within post but not move towards to the player?

Hello so basically I make a 2d top-down soccer game but I have to trouble with GK AI, I want to GK is followed the ball but not move toward on it

let say (Enemy = GK) enter image description here

enter image description here

so when the player moves to the left or right the enemy will follow to the right or left not The Yaxis but in X-axis with guarding the post or Y=0

my default enemy movement is like this :

if (gameObject.CompareTag("GK"))         {              anim.SetBool("GKRun", false);             gkballInRange = Physics2D.OverlapCircle(transform.position, gkballRange, playerMask);             float distancePlayer = Vector2.Distance(target.position, transform.position);              if (gkballInRange)             {                 if (distancePlayer <= gkballRange)                 {                     //Animation                     anim.SetBool("GKRun", true);                     transform.Translate(0, -speed * Time.deltaTime, 0);                 }             }          } 

in that scrip, when the ball is on the range the GK is moving to the ball just that. maybe anyone can explain to me how to do it?