Pong - Ball getting stuck infinitely bouncing at 90 degrees and linear velocity change does nothing
Hi,
I've never built a game before but I worked through this Pong tutorial - http://computerlab200.webs.com/pong-tutorial - and adapted it to be a two-player game. It works fine most of the time but sometimes the ball seems to bounce off the top or bottom wall at close to 90 degrees, and then it just bounces back and forth between the walls and never reaches either of the paddles again.
I've seen this discussion http://forums.gamesalad.com/discussion/56979/bounce-ball-issues-help - which describes exactly what I'm experiencing, and I've tried what the thread suggests, detecting when the linear velocity of X or Y is near zero (I've done (-4,4) to be on the safe side) and then generating a random linear velocity on the same axis in the range (-45,45).
But it doesn't work at all - in fact it doesn't seem to do anything! I've switched on text display of the linear velocity, and It doesn't seem to matter how close it gets to zero, it just keeps bouncing back and forth between the walls at about 90 degrees. The text display just continues to show it nearing zero. I have also tried adding a debugger log to the statements and the messages aren't printing out when the ball gets stuck.
Clearly the velocity change isn't triggering for some reason, but I've spent hours looking at it and I just can't figure out why Can anyone help? I don't appear to be able to post attachments but here's a screenshot of my settings for the ball: http://oi57.tinypic.com/3308ec0.jpg
I have the same settings on both linear velocity.x and linear velocity.y.
If anyone can help me out I'd really appreciate it - I'm really confused as to why changing the velocity attribute isn't working.