Having prior programming experience, I made my own fix to this solution. Still needs a few tweaks, but it does work:
On bounce, check the current velocity. If the Y velocity is within a certain range (I’ve tried -0.4 to 0.4 but that might need to be raised) I accelerate the ball’s velocity in that direction by 0.4 in the direction it was moving. If the X velocity is within the same numeric range, I determine which side of the screen it’s on and change its velocity to move towards the center of the screen in an effort to keep the ball from being trapped against the wall.
As said, this trick has worked, but the numbers still need some tweaking because I think a velocity of 0.5 still can allow for some seriously long boring loops (which seem to happen most in Y Velocity for me).
[details=My Code (Unity 5, should still work with Unity 4)] Vector2 Velocity = this.GetComponent().velocity;
if (Velocity.y < 0.4 && Velocity.y > 0) {
Velocity.y += 0.4f;
Debug.LogWarning (“Avoiding Boring State with += YVel”);
this.GetComponent().velocity += Velocity;
} else if (Velocity.y > -0.4 && Velocity.y <= 0) {
Velocity.y -= 0.4f;
Debug.LogWarning (“Avoiding Boring State with -= YVel”);
this.GetComponent().velocity += Velocity;
}
if (Velocity.x > -0.4 && Velocity.x < 0.3) {
float ballPos = this.transform.position.x;
if (ballPos <= 8) {
Velocity.x += 0.4f;
this.GetComponent ().velocity += Velocity;
} else {
Velocity.x -= 0.4f;
this.GetComponent ().velocity += Velocity;
}
}[/details]
Advanced Fix Ideas
One thing I really think would help with this problem in my code, in particular, is for the Vertical Boring Loop is actually modifying the velocity to the Absolute Value of its movement +/- the 0.4 increase. This would require using some Math functions not covered in the course, though.