1
\$\begingroup\$

I'm trying to create bouncing balls with realistic physics. At the moment, when the balls hit each other, they bounce back in the same direction they came from. How do I make them more realistic?

I don't know much about physics. What things should I be reading about?

Here's an image of how I imagine balls would bounce in real life:

how I think it should work (original source: http://thewombatguru.nl/Bouncing.png):

enter image description here

Is this how it works?

\$\endgroup\$
2
\$\begingroup\$

It kinda depends on what you're making.

If you're making a game about physics, you could conceivably write your own physics engine, however I do not recommend it. There are many 2D and 3D physics engines already out there that you can use that will save you months of work.

My first time using Box2d was intimidating, and I'll admit it has a fair learning curve. However unless you're a physics genius, the amount of time you spend figuring out Box2d will be significantly less than the amount of time you'd have spent writing your own physics, and I can guarantee the results will be better.

If you insist on writing your own physics... well you've been warned :P There are many articles online about 2D ball to ball collision, you'll just have to do the hard work of converting articles to code. If you aren't worried about spin, it's not too unreasonable of a job... but it will still be a lot of work.

Good luck!

\$\endgroup\$
  • 2
    \$\begingroup\$ Idk man, I wrote my own 3D physics library and that only took a few months. I wouldn't completely knock the idea. \$\endgroup\$ – CoffeeandCode Jun 18 '15 at 7:39
  • \$\begingroup\$ Spin isn't difficult. Find the collision point, project it onto the collision vector, and push in that direction. For spin just spin it that way (CW or CCW) with an angular velocity proportional to the distance from the collision point to the projected point. For 2D games, physics is pretty simple. Also, Verlet integration is your friend. \$\endgroup\$ – 3Dave Jul 27 '18 at 20:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.