Pong Game AI Problems

Hey guys my first time on this forum, im trying to make a pong game, and i just can’t make it so that the Ai is beatable xD

i have tried thinking of many ways so it would be nice with some help

sincerely Emil

Heres my code:

function Update()
{
	if (HitIt == false)
	{
	EnemyZ = gameObject.Find("Enemy").transform.position.z;
	BallZ = gameObject.Find("Ball").transform.position.z;
	if (EnemyZ < 2.134014)
	{
		EnemyZ += BallZ;
		var Enemyspos : float;
		Enemyspos = EnemyZ;
		transform.Translate(Vector3(0,0,Enemyspos) * Time.deltaTime);
	
	}else if (EnemyZ > 2.034014) {
	
		EnemyZ -= BallZ;
		var EnemyPos2 : float;
		EnemyPos2 = EnemyZ;
		transform.Translate(Vector3(0,0,EnemyPos2) * Time.deltaTime);		
	
	}else {}
}
}

Rather than correcting the pads position to the ball with every update you could you record the balls current position and move towards that via infrequent updates. For example

if(Random(min, max) == 1)
updateTargetPos();

MoveTowardsTargetPos()

so the pad will always move towards the target position but the target position will be updated infrequently with more frequent updates signifying difficulty. This is just of the top of my head though perhaps there is a better way of doing this in pong idk.

You could also attempt to determine the balls end position based of the velocity and have the pad move towards that position with an added random offset.