Make a Bot Player? : UNITY2D

I’m a noob at unity and semi-noob to java (which is what I’m using). Anyways I am making a simple pong game but my problem is that instead of having to control both players, I want to make it a one player game where one of the “rackets” is a bot and plays on its own. I have no idea where to start on that code. Any suggestions?

You’re not using Java.

Unity doesn’t program in Java.

I suspect you are using Unityscript, which is a flavor of Javascript, which has nothing to do with Java whatsoever except the first 4 letters.

Now, for pong AI, click here…

If you want an unwinnable AI to control the rackets, take the ball’s y position ( rigidbody2D.position.y) and set it as the racket’s y position. It’s unwinnable because the racket will always be going the same speed as the ball. To make it more balanced, make it so a force is applied to the racket until reaches the y position of the ball.