3
\$\begingroup\$

Usually, in most physics engines that are out there, the way that collisions are solved is by applying some impulse to both colliding bodies.

While I understand that impulses are just force that is already integrated into time, and will result into velocity added at the end of the frame, why not simply project both bodies out of collision and removing their velocity component that is going towards the collision?

I'm not really sure, but it really looks like classic platformers only stopped the character instead of adding impulse to it. Is this right?

And if yes, why the added complexity of using impulses in modern engines?

\$\endgroup\$
3
  • \$\begingroup\$ If you want to use a physics engine to take care of a lot of hassles, then it has to work with the integrator. If you are ok with handling every physical interaction yourself, you can do it the way the classic games did. \$\endgroup\$
    – Almo
    Commented Mar 21, 2017 at 3:47
  • \$\begingroup\$ Game engines are for general case application. They are built to do many things. With this in mind the application of physics can account for the specific circumstance you described and much more. An object of infinite mass meeting an object with 0 elasticity is what you're describing. All energy is lost when the object is hit. \$\endgroup\$ Commented Mar 21, 2017 at 4:21
  • 1
    \$\begingroup\$ It has to do with the solver, mostly based on constrained optimization problem solutions. Physics engines are 99% of the time concerned with resolving collisions, and that is done via expressing the current geometric situation in terms of contact points and the impulses required to prevent bodies from penetrating. LCP is the most basic formulation: gamedev.net/topic/…. Of course, there are more complex aspects, but this is the 101.. \$\endgroup\$
    – teodron
    Commented Mar 21, 2017 at 10:52

1 Answer 1

2
\$\begingroup\$

In (real-life) physics there is the principle of conservation of momentum. in a collision between objects the sum of their momenta needs to be the same before and after the collision. In other words m1*v1 + m2*v2 = m1*v1' + m2*v2'.

If you have 2 physics enabled objects colliding in a non-elastic collision (they end up stuck together) what will the final speeds of the combined object be? The answer is the sum of their momenta. The way to ensure that this is the case is by making sure the change in momentum in both object are opposite and equal in magnitude. This change in momentum is the impulse.

When colliding non-spherical objects the location of the impulse also lets the simulator impart some rotation onto the object if the impulse isn't aligned to the center of mass.

The other important component in physics simulation is conservation of energy, where the total energy of the system must be maintained (or converted to other forms). This means that m1*dot(v1,v1) + m2*dot(v2,v2) = lossFactor*(m1*dot(v1',v1') + m2*dot(v2',v2')). Making sure that lossFactor is less than 1 is important to make avoid crazy behavior that ends up with massive speeds.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .