I am implementing the collisions of my game in javascript, and at the moment what happens when the objects collide is that they have their speed changed to 0. What I'm starting to want to do is to make it a little more interesting when the player plays with other objects in motion, they collide and separate. This is a very physical 2D issue itself. If an object A is at positive velocity at x collides with an object B is at negative velocity at x, collide head-on, what would be the best calculation to do so that they separate naturally after the collision?

What if they go in the same direction in x? and if one has going on x and another on y? How do I deal with all this?

Should I add mass and acceleration to make this separation calculation after the collision?

  • \$\begingroup\$ gamedev.stackexchange.com/q/154054/67769 \$\endgroup\$ – Bálint Jul 12 '18 at 18:13
  • \$\begingroup\$ @Bálint This is very good, your response was very clear there, but the acceleration? I ask, because in my game objects have acceleration. \$\endgroup\$ – PerduGames Jul 12 '18 at 18:52
  • \$\begingroup\$ Collisions don't involve change in acceleration. \$\endgroup\$ – Bálint Jul 12 '18 at 22:50
  • \$\begingroup\$ @Bálint I'm confused by "Ian Young" response. \$\endgroup\$ – PerduGames Jul 12 '18 at 23:07
  • \$\begingroup\$ You're changing the velocity. That's basically applying acceleration, that only lasts for a very short time (in an ideal world it's instantenious). That's what he means by "Once this impulse is used, it is discarded". Acceleration doesn't actually exist. You can't apply acceleration to something for a long time without also applying force. You could calculate the same thing with forces, but kinematics already simplified this for you, so why bother. \$\endgroup\$ – Bálint Jul 12 '18 at 23:42

Your Answer

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

Browse other questions tagged or ask your own question.