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 {}
}
}