# Collisions between two objects in 2D space

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?

• gamedev.stackexchange.com/q/154054/67769 Commented Jul 12, 2018 at 18:13
• @Bálint This is very good, your response was very clear there, but the acceleration? I ask, because in my game objects have acceleration. Commented Jul 12, 2018 at 18:52
• Collisions don't involve change in acceleration. Commented Jul 12, 2018 at 22:50
• @Bálint I'm confused by "Ian Young" response. Commented Jul 12, 2018 at 23:07
• 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. Commented Jul 12, 2018 at 23:42