This project has moved. For the latest updates, please go here.

Collision impact (yes, again...)

Jul 3, 2011 at 4:29 PM

I need to know the impact of a collision. I've asked this before, but it seems to have changed in the newer releases (using 3.3.1 now). 

I've registered an OnCollision eventhandler and there I have this code. This used to work in the early FP3.0 release. But whatever impact two bodies have now, the NormalImpuls of the contactpoints is always zero, and thus the maxImpulse.

private bool PhysicsBody_OnCollision(Fixture fixtureA, Fixture fixtureB, Contact contact)
            float maxImpulse = 0.0f;
            Manifold manifold;
            contact.GetManifold(out manifold);
            for (int i = 0; i < manifold.PointCount; ++i)
                maxImpulse = Math.Max(maxImpulse, manifold.Points[i].NormalImpulse);
            if (maxImpulse >= 30)
                // big impact
            return true;

Does anybody know what's going wrong?

Jul 5, 2011 at 7:35 AM

Ok, just for the record; I had to use the AfterCollision event, which can only be found in a fixture.

Jul 23, 2011 at 5:29 PM

Nice!  I was just working on the same thing and wondering why collision values were zero or 2.2323e-16 =0


Good work there!