Hopefully someone can find this useful. This is my fix for the Block Breaker game where the ball will slow down until the game is unplayable. With this fix I was able to auto-play my game (5 levels) all the way through 2/3 times on my first test. Before the fix, I could try 5 times and still not be able to auto-play through once. On Ball.cs:
private void OnCollisionEnter2D (Collision2D collision)
{
//Artificial physics to try and stop infinite looping. TODO find a better fix.
Vector2 velocityTweak = new Vector2(Random.Range(0f, randomFactor),
Random.Range(0f, randomFactor));
if (hasStarted)
{
AudioClip clip = ballSounds[UnityEngine.Random.Range(0, ballSounds.Length)];
myAudioSource.PlayOneShot(clip);
//Assigns the balls speed to 15 and keeps it there
myRB2D.velocity = myRB2D.velocity.normalized * 15f;
//Add the random tweak to the set velocity of 15 (I do 0.4, seems to work well).
//This gives us a value between ~14.6 and ~15.4 every time
myRB2D.velocity += velocityTweak;
print(myRB2D.velocity.magnitude);
}
}