To fix the boring ball loops I added the following function. I used mathf.Sign() to ensure the ball continued in the same direction.
private void CheckVelocity()
{
Vector2 currentVelocity = myRigidBody.velocity;
if (Mathf.Abs(currentVelocity.y) < 1f)
{
Vector2 newVelocity = new Vector2(currentVelocity.x, Mathf.Sign(currentVelocity.y) * 2f);
myRigidBody.velocity = newVelocity;
}
if (Mathf.Abs(currentVelocity.x) < .25f)
{
Vector2 newVelocity = new Vector2(Mathf.Sign(currentVelocity.x) * 2f , currentVelocity.y);
myRigidBody.velocity = newVelocity;
}
}
Then I added a timestamp to check for time since the last time the ball hit anything in order to check the velocities after the hit not during. I found that if the velocity was checked at the exact instant of impact then the velocities were near zero. I update the timestamp in the OnCollisionEnter2D function and then check that it has been .1 second since last hit with this if Statement in the Update function. I added the hitHasOccured test to prevent the CheckVelocity function from being called on every Update between the velocity corrections and the next hit.
if (hitHasOccured && Time.timeSinceLevelLoad - timeSinceLastHit > .1f)
{
CheckVelocity();
hitHasOccured = false;
}
Edit: corrected some grammer