I have a problem with .find in Unity.

Hi, I am having a few problems with my game in unity I have created to play against the computer in a ball game the problem is the fact that I have made the computer completely impossible to beat unless the speed of the ball glitches through the Paddles / Bats.

If anyone has any way for me to be able to make the computer have like a percentage chance to get the ball would be great help.

Thanks Lenny... Code is Below.

This is my Code for the Ball:

1. var speed : float;

var speedX : float;

var speedY : float;

var ball : GameObject;

var score :GameScore;

function Reset() {

transform.position = new Vector3(0, 0, 250);

speed = 200;

speedX = speed;

speedY = speed;

rigidbody.velocity = new Vector3(speedX, speedY, 0);

score = GameObject.Find("Game Score").GetComponent(GameScore);

}

function Start() {

Reset();

}

function Update() {

if (transform.position.y > 210) {

speedY *= -1;

transform.position.y = 210;

rigidbody.velocity = new Vector3(speedX, speedY, 0);

}

if (transform.position.y < -210) {

speedY *= -1;

transform.position.y = -210;

rigidbody.velocity = new Vector3(speedX, speedY, 0);

}

if (transform.position.x > 550) {

Reset();

score.computerScore = score.computerScore +1;

}

if (transform.position.x < -550) {

Reset();

score.playerScore = score.playerScore +1;

}

}

function OnCollisionEnter(collision :Collision) {

var other = collision.gameObject;

speed *= 1.1;

if (transform.position.x > other.transform.position.x) {

speedY = speedY > 0 ? -speed : speed;

rigidbody.velocity = new Vector3(speedX, speedY, 0);

else {

if (transform.position.y > other.transform.position.y) {

speedX = speedX > 0 ? -speed : speed;

speedY = speed;

rigidbody.velocity = new Vector3(speedX, speedY, 0);

else {

speedX = speedX > 0 ? -speed : speed;

speedY = -speed;

rigidbody.velocity = new Vector3(speedX, speedY, 0);

}

}

}

if (transform.position.x < other.transform.position.x) {

speedY = speedY > 0 ? -speed : speed;

rigidbody.velocity = new Vector3(speedX, speedY, 0);

else {

if (transform.position.y > other.transform.position.y) {

speedX = speedX > 0 ? -speed : speed;

speedY = speed;

rigidbody.velocity = new Vector3(speedX, speedY, 0);

else {

speedX = speedX > 0 ? -speed : speed;

speedY = -speed;

rigidbody.velocity = new Vector3(speedX, speedY, 0);

}

}

}

}

And this is my Code for the Opponent to Find the Ball:
1. var speed = 600;

function Update () {

var ball = GameObject.Find("Ball") ="%" =80;

if (ball.transform.position.y > transform.position.y) {

transform.position.y = Mathf.Min(transform.position.y + speed * Time.deltaTime,  ball.transform.position.y);

}

else if (ball.transform.position.y < transform.position.y) {

transform.position.y = Mathf.Max(transform.position.y - speed * Time.deltaTime,  ball.transform.position.y);

}

}