- Home /
2D pong game. HELP
Hi I'm new to Unity 3D and I'm trying to make a pong game. equal to the image. http://gamefroot.com/wp-content/files/2012/06/pongpic.png
My questions are:
1) How do I get the ball never stops moving
2) That leaves the ball in different directions when the game starts
Thank you for your help
[1]: http://gamefroot.com/wp-content/files/2012/06/pongpic.png
Comment
Answer by robertbu · Aug 02, 2014 at 07:29 PM
1) Set the velocity to something specific in FixedUpdate():
function FixedUpdate() {
rigidbody2D.velocity = rigidbody2D.velocity.normalized * speed;
}
2) Pick a random initial direction for the ball:
rigidbody2D.velocity = Quaternion.AngleAxis(Random.Range(0,360), Vector3.forward) * Vector3.up * speed;