The ball’s velocity has driven me nuts for days. I tried dragging the “bouncing” material to everywhere, modifying the rigidbody2D properties… It didn’t work. Sometimes the ball accelerated, sometimes the ball seemed to freeze.
I think today I have found where is the problem.
myRigidbody2D.velocity += velocityTweak;
The Rigidbody.velocity can increase or decrease without limits.
My solution (it is not an ideal solution!!):
myRigidbody2D.velocity += velocityTweak; if (myRigidbody2D.velocity.magnitude < (0.9f * myVelocity)) myRigidbody2D.velocity = myRigidbody2D.velocity * 1.1f; else if (myRigidbody2D.velocity.magnitude > (1.1f * myVelocity)) myRigidbody2D.velocity = myRigidbody2D.velocity * 0.9f;
In the Start():
myVelocity = Mathf.Sqrt(xVel * xVel + yVel * yVel);