- Home /
Increasing the speed of a ball in a brick breaker game
Hi guys, just starting a tuto and I'd like to constantly increase the speed of my ball, but damn I'm so bad at maths I can't even figure how to do, here's what I do at the moment :
// I'm giving the first force (random x) when you engage the ball, in the Start method
System.Random xForce = new System.Random();
rigidBody.AddForce(new Vector2(xForce.Next((int)-speed, (int)speed), speed);
// Later, in the Update code, I use this
rigidBody.AddForce(rigidBody.velocity* speedUp);
speed and speedUp are public variables.
What is bothering me is when I add my first force, I guess that a Vector2(speed, speed) will make a faster ball than (0, speed) right ? So I'd like a way to change the direction of my force, but with the same speed resulting for the eye of the player.
Also, when I increase my speed, I do velocity* speedUp, which means (I still guess) that a Vector2(speed, speed) will increase more than a (0, speed) right ? So I'd like to increase it in the same way no matter the direction of my ball.
I don't know if I'm being clear, I read about normalized vectors on a thread but I don't understand it that's why I'm asking your help guys, thanks in advance !
Your answer
![](https://koobas.hobune.stream/wayback/20220612203031im_/https://answers.unity.com/themes/thub/images/avi.jpg)