Bouncing ball bounces too much


Hey guys, I’m trying to make a pinball game. I want the ball to bounce off of walls but also eventually come to a stop. I have se the sprite to bounce on the wall. I have also given it an Y acceleration.

The ball starts at Y 0 with zero velocity

Expected behavior: ball accelerates to a wall, bounces and then doesn’t quite make it back to Y 0 because of the ay. Each bounce isn’t as high as the last. (you know, like a ball :slight_smile:

What happens: the ball actually goes beyond Y 0 cause each bounce to go higher than the last until it reaches the opposite wall. The ball accelerates infinitely.

I’m not sure if I did something wrong or I can add something simple to make it work right! Thanks! Still new with all this.

Can you post your code? (as a link) It seems right in the screenshot you gave us but maybe something fishy is going on with the rest?

Here is the link.
You can see the ball keep bouncing higher and higher if you leave it alone.

1 Like

I tested this on the side of the screen as well as my tilemap walls. Same thing happens, the ball bounces higher than it fell.

This one’s a known bug – the root cause of the issue is that we calculate the change in velocity due to acceleration once per sprite at the beginning of the frame, but the bounce is happening part way through the frame, resulting in a slightly higher velocity than you would expect.

I’m hoping to get a chance to fix this in some way for the next release – getting it exactly right might not be feasible without impacting performance, but we should be able to get it closer to correct and we can probably also support friction along with acceleration (as right now only one of the two will work at the same time) to make the interaction more realistic.


Ah I was just messing with friction trying to get it to work when I read your reply.

Thank you so much. Sounds like friction working with acceleration is what I need. I can’t wait to see it updated! Thank you for the info.

Check out my little work around :smiley: